1- import { fromHex , toHex } from "@cosmjs/encoding" ;
1+ import { fixUint8Array , fromHex , toHex } from "@cosmjs/encoding" ;
22import { assert } from "@cosmjs/utils" ;
33import { secp256k1 } from "@noble/curves/secp256k1" ;
44
@@ -106,7 +106,7 @@ export class Secp256k1 {
106106 bytesToUnsignedBigInt ( signature . s ( ) ) ,
107107 signature . recovery ,
108108 ) . recoverPublicKey ( messageHash ) ;
109- return pk . toBytes ( false ) ;
109+ return fixUint8Array ( pk . toBytes ( false ) ) ;
110110 }
111111
112112 /**
@@ -117,9 +117,9 @@ export class Secp256k1 {
117117 public static compressPubkey ( pubkey : Uint8Array ) : Uint8Array < ArrayBuffer > {
118118 switch ( pubkey . length ) {
119119 case 33 :
120- return pubkey ;
120+ return fixUint8Array ( pubkey ) ;
121121 case 65 :
122- return secp256k1 . Point . fromBytes ( pubkey ) . toBytes ( true ) ;
122+ return fixUint8Array ( secp256k1 . Point . fromBytes ( pubkey ) . toBytes ( true ) ) ;
123123 default :
124124 throw new Error ( "Invalid pubkey length" ) ;
125125 }
@@ -133,9 +133,9 @@ export class Secp256k1 {
133133 public static uncompressPubkey ( pubkey : Uint8Array ) : Uint8Array < ArrayBuffer > {
134134 switch ( pubkey . length ) {
135135 case 33 :
136- return secp256k1 . Point . fromBytes ( pubkey ) . toBytes ( false ) ;
136+ return fixUint8Array ( secp256k1 . Point . fromBytes ( pubkey ) . toBytes ( false ) ) ;
137137 case 65 :
138- return pubkey ;
138+ return fixUint8Array ( pubkey ) ;
139139 default :
140140 throw new Error ( "Invalid pubkey length" ) ;
141141 }
@@ -144,7 +144,7 @@ export class Secp256k1 {
144144 public static trimRecoveryByte ( signature : Uint8Array ) : Uint8Array < ArrayBuffer > {
145145 switch ( signature . length ) {
146146 case 64 :
147- return signature ;
147+ return fixUint8Array ( signature ) ;
148148 case 65 :
149149 return signature . slice ( 0 , 64 ) ;
150150 default :
0 commit comments