const tweetnacl=require('tweetnacl') import {CurveTypeStr} from './type' export class PrivateKey{ CurveType:string=CurveTypeStr.Ed25519 PrivateKey:string constructor(privateKey:string){ this.PrivateKey=privateKey } setCurveType(curveType){ this.CurveType=curveType } sign(msg:Buffer){ switch (this.CurveType){ case CurveTypeStr.Ed25519: let msgArray=Uint8Array.from(msg) return tweetnacl.sign.detached(msgArray, Buffer.from(this.PrivateKey,'hex')) case CurveTypeStr.Secp256k1: throw new Error('CurveType Secp256k1 is not implemented') default: throw new Error('invalid curve type') } } }