@@ -18,7 +18,7 @@ import {
1818 isBytes ,
1919 memoized ,
2020 notImplemented ,
21- randomBytes as wcRandomBytes ,
21+ randomBytes as randomBytesWeb ,
2222 type FHash ,
2323 type Hex ,
2424} from '../utils.ts' ;
@@ -531,7 +531,8 @@ export function edwards(params: EdwardsOpts, extraOpts: EdwardsExtraOpts = {}):
531531 return this . toBytes ( ) ;
532532 }
533533 }
534- const wnaf = new wNAF ( Point , Fn . BYTES * 8 ) ; // Fn.BITS?
534+ const wnaf = new wNAF ( Point , Fn . BITS ) ;
535+ Point . BASE . precompute ( 8 ) ; // Enable precomputes. Slows down first publicKey computation by 20ms.
535536 return Point ;
536537}
537538
@@ -665,7 +666,7 @@ export function eddsa(Point: EdwardsPointCons, cHash: FHash, eddsaOpts: EdDSAOpt
665666 const { prehash } = eddsaOpts ;
666667 const { BASE , Fp, Fn } = Point ;
667668
668- const randomBytes = eddsaOpts . randomBytes || wcRandomBytes ;
669+ const randomBytes = eddsaOpts . randomBytes || randomBytesWeb ;
669670 const adjustScalarBytes = eddsaOpts . adjustScalarBytes || ( ( bytes : Uint8Array ) => bytes ) ;
670671 const domain =
671672 eddsaOpts . domain ||
@@ -765,8 +766,6 @@ export function eddsa(Point: EdwardsPointCons, cHash: FHash, eddsaOpts: EdDSAOpt
765766 return RkA . subtract ( SB ) . clearCofactor ( ) . is0 ( ) ;
766767 }
767768
768- BASE . precompute ( 8 ) ; // Enable precomputes. Slows down first publicKey computation by 20ms.
769-
770769 const _size = Fp . BYTES ; // 32 for ed25519, 57 for ed448
771770 const lengths = {
772771 secret : _size ,
@@ -781,11 +780,9 @@ export function eddsa(Point: EdwardsPointCons, cHash: FHash, eddsaOpts: EdDSAOpt
781780 const secretKey = utils . randomSecretKey ( seed ) ;
782781 return { secretKey, publicKey : getPublicKey ( secretKey ) } ;
783782 }
784-
785783 function isValidSecretKey ( key : Uint8Array ) : boolean {
786784 return isBytes ( key ) && key . length === Fn . BYTES ;
787785 }
788-
789786 function isValidPublicKey ( key : Uint8Array , zip215 ?: boolean ) : boolean {
790787 try {
791788 return ! ! Point . fromBytes ( key , zip215 ) ;
0 commit comments