import { aes256CbcDecrypt } from "../crypto/encryptions" ; import * as signatureTools from "../crypto/signature" ; description param { String } encryptedSignature param { String } signatureKey param { Boolean } isEDDSA param { Boolean } returnCanonical return { { r : string , s : string } | Buffer } export const decryptSignatureFromSE = ( encryptedSignature , signatureKey , isEDDSA = false , returnCanonical = true ) : { r : string ; s : string ; } | Buffer => { const iv = Buffer . alloc ( 16 ) ; iv . fill ( 0 ) ; const derSigBuff = aes256CbcDecrypt ( iv , Buffer . from ( signatureKey , "hex" ) , encryptedSignature ) ; if ( isEDDSA ) return derSigBuff ; const sigObj = signatureTools . parseDERsignature ( derSigBuff . toString ( "hex" ) ) ; const canonicalSignature = signatureTools . getCanonicalSignature ( sigObj ) ; if ( returnCanonical ) return canonicalSignature ; return signatureTools . convertToDER ( canonicalSignature ) ; } ; param { String } addressIndexToKeyId param { String } addressIndex export const addressIndexToKeyId = ( coinType , addressIndex ) => { const indexHex = addressIndex . toString ( 16 ) . padStart ( 4 , "0" ) ; const keyId = `${ coinType }0000${ indexHex }` ; return keyId ; } ;