@@ -28,7 +28,7 @@ import {
2828 Curve ,
2929 encParamsHexToBuf ,
3030 hexToBytes ,
31- keccak256 ,
31+ keccak256Bytes ,
3232 numberToBytesBE ,
3333 toBigIntBE ,
3434 utf8ToBytes ,
@@ -62,21 +62,21 @@ export function convertMetadataToNonce(params: { message?: string }): bigint {
6262
6363export async function decryptNodeData ( eciesData : EciesHex , ciphertextHex : string , privKey : Uint8Array ) : Promise < Uint8Array > {
6464 const metadata = encParamsHexToBuf ( eciesData ) ;
65- const decryptedSigBuffer = await decrypt ( privKey , {
65+ const decryptedSigBytes = await decrypt ( privKey , {
6666 ...metadata ,
6767 ciphertext : hexToBytes ( ciphertextHex ) ,
6868 } ) ;
69- return decryptedSigBuffer ;
69+ return decryptedSigBytes ;
7070}
7171
7272export async function decryptNodeDataWithPadding ( eciesData : EciesHex , ciphertextHex : string , privKey : Uint8Array ) : Promise < Uint8Array > {
7373 const metadata = encParamsHexToBuf ( eciesData ) ;
7474 try {
75- const decryptedSigBuffer = await decrypt ( privKey , {
75+ const decryptedSigBytes = await decrypt ( privKey , {
7676 ...metadata ,
7777 ciphertext : hexToBytes ( ciphertextHex ) ,
7878 } ) ;
79- return decryptedSigBuffer ;
79+ return decryptedSigBytes ;
8080 } catch ( error ) {
8181 // ciphertext can be any length. not just 64. depends on input. we have this for legacy reason
8282 const ciphertextHexPadding = ciphertextHex . padStart ( 64 , "0" ) ;
@@ -92,7 +92,7 @@ export function generateMetadataParams(ecCurve: Curve, serverTimeOffset: number,
9292 data : message ,
9393 timestamp : ( ~ ~ ( serverTimeOffset + Date . now ( ) / 1000 ) ) . toString ( 16 ) ,
9494 } ;
95- const msgHash = hexToBytes ( keccak256 ( utf8ToBytes ( stringify ( setData ) ) ) . slice ( 2 ) ) ;
95+ const msgHash = keccak256Bytes ( utf8ToBytes ( stringify ( setData ) ) ) ;
9696 // metadata only uses secp for sig validation; prehash: false because msgHash is already hashed
9797 const sig = secp256k1 . sign ( msgHash , hexToBytes ( bigintToHex ( privateKey ) ) , { prehash : false } ) ;
9898 const pubKey = ecCurve . Point . BASE . multiply ( privateKey ) . toAffine ( ) ;
@@ -145,7 +145,7 @@ export function generateNonceMetadataParams(
145145 setData . seed = "" ; // setting it as empty to keep ordering same while serializing the data on backend.
146146 }
147147
148- const msgHash = hexToBytes ( keccak256 ( utf8ToBytes ( stringify ( setData ) ) ) . slice ( 2 ) ) ;
148+ const msgHash = keccak256Bytes ( utf8ToBytes ( stringify ( setData ) ) ) ;
149149 const sig = secp256k1 . sign ( msgHash , hexToBytes ( bigintToHex ( privateKey ) ) , { prehash : false } ) ;
150150 const pubKey = secp256k1 . Point . BASE . multiply ( privateKey ) . toAffine ( ) ;
151151 return {
@@ -256,7 +256,7 @@ export async function getOrSetSapphireMetadataNonce(
256256 operation : "getOrSetNonce" ,
257257 timestamp : ( ~ ~ ( serverTimeOffset + Date . now ( ) / 1000 ) ) . toString ( 16 ) ,
258258 } ;
259- const msgHash = hexToBytes ( keccak256 ( utf8ToBytes ( stringify ( setData ) ) ) . slice ( 2 ) ) ;
259+ const msgHash = keccak256Bytes ( utf8ToBytes ( stringify ( setData ) ) ) ;
260260 const sig = secp256k1 . sign ( msgHash , hexToBytes ( bigintToHex ( privKey ) ) , { prehash : false } ) ;
261261 const pubKey = secp256k1 . Point . BASE . multiply ( privKey ) . toAffine ( ) ;
262262 data = {
0 commit comments