File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ export const MAX_LENGTH_DB_VALUE: number = 128 * 1024;
11
11
export const MAX_LENGTH_CANONICAL_ADDRESS : number = 64 ;
12
12
export const MAX_LENGTH_HUMAN_ADDRESS : number = 256 ;
13
13
14
+ export const MAX_LENGTH_ED25519_SIGNATURE : number = 64 ;
15
+ export const MAX_LENGTH_ED25519_MESSAGE : number = 128 * 1024 ;
16
+ export const EDDSA_PUBKEY_LEN : number = 32 ;
17
+
14
18
export class VMInstance {
15
19
public instance ?: WebAssembly . Instance ;
16
20
public bech32 : BechLib ;
@@ -378,6 +382,10 @@ export class VMInstance {
378
382
signature : Region ,
379
383
pubkey : Region
380
384
) : number {
385
+ if ( message . length > MAX_LENGTH_ED25519_MESSAGE ) return 1 ;
386
+ if ( signature . length > MAX_LENGTH_ED25519_SIGNATURE ) return 1 ;
387
+ if ( pubkey . length > EDDSA_PUBKEY_LEN ) return 1 ;
388
+
381
389
const sig = Buffer . from ( signature . data ) . toString ( 'hex' ) ;
382
390
const pub = Buffer . from ( pubkey . data ) . toString ( 'hex' ) ;
383
391
const msg = Buffer . from ( message . data ) . toString ( 'hex' ) ;
Original file line number Diff line number Diff line change @@ -591,7 +591,7 @@ describe('do_ed25519_verify', () => {
591
591
expect ( result ) . toEqual ( 1 ) ;
592
592
} ) ;
593
593
594
- it . skip ( 'fails for large sig' , ( ) => { // test is broken, only ever passed due to other tests mutating the test data
594
+ it ( 'fails for large sig' , ( ) => {
595
595
const sig = new Uint8Array ( [ ...testData . EDDSA_SIG_HEX , 0x00 ] ) ;
596
596
const hashPtr = writeData ( vm , testData . EDDSA_MSG_HEX ) ;
597
597
const sigPtr = writeData ( vm , sig ) ;
You can’t perform that action at this time.
0 commit comments