@@ -669,28 +669,6 @@ const unpack25519 = (o, n) => {
669
669
o [ 15 ] &= 0x7fff ;
670
670
} ;
671
671
672
- export const cleanup = ( arr ) => {
673
- for ( let i = 0 ; i < arr . length ; i ++ ) {
674
- arr [ i ] = 0 ;
675
- }
676
- } ;
677
-
678
- export const crypto_shared_key_hash = ( shared , pk , sk , hashfunc ) => {
679
- const d = new Uint8Array ( 64 ) ;
680
- const p = [ gf ( ) , gf ( ) , gf ( ) , gf ( ) ] ;
681
-
682
- hashfunc ( d , sk , 32 ) ;
683
- d [ 0 ] &= 248 ;
684
- d [ 31 ] &= 127 ;
685
- d [ 31 ] |= 64 ;
686
-
687
- const q = [ gf ( ) , gf ( ) , gf ( ) , gf ( ) ] ;
688
- // tslint:disable: no-use-before-declare
689
- unpackneg ( q , pk ) ;
690
- scalarmult ( p , q , d ) ;
691
- pack ( shared , p ) ;
692
- } ;
693
-
694
672
export const crypto_verify_32 = ( x , xi , y , yi ) => {
695
673
return vn ( x , xi , y , yi , 32 ) ;
696
674
} ;
@@ -728,47 +706,6 @@ export const add = (p, q) => {
728
706
M ( p [ 3 ] , e , h ) ;
729
707
} ;
730
708
731
- export const modL = ( r , x ) => {
732
- // tslint:disable-next-line:one-variable-per-declaration
733
- let carry , i , j , k ;
734
- for ( i = 63 ; i >= 32 ; -- i ) {
735
- carry = 0 ;
736
- for ( j = i - 32 , k = i - 12 ; j < k ; ++ j ) {
737
- x [ j ] += carry - 16 * x [ i ] * L [ j - ( i - 32 ) ] ;
738
- carry = ( x [ j ] + 128 ) >> 8 ;
739
- x [ j ] -= carry * 256 ;
740
- }
741
- x [ j ] += carry ;
742
- x [ i ] = 0 ;
743
- }
744
- carry = 0 ;
745
- for ( j = 0 ; j < 32 ; j ++ ) {
746
- x [ j ] += carry - ( x [ 31 ] >> 4 ) * L [ j ] ;
747
- carry = x [ j ] >> 8 ;
748
- x [ j ] &= 255 ;
749
- }
750
- for ( j = 0 ; j < 32 ; j ++ ) {
751
- x [ j ] -= carry * L [ j ] ;
752
- }
753
- for ( i = 0 ; i < 32 ; i ++ ) {
754
- x [ i + 1 ] += x [ i ] >> 8 ;
755
- r [ i ] = x [ i ] & 255 ;
756
- }
757
- } ;
758
-
759
- export const reduce = ( r ) => {
760
- // tslint:disable-next-line:one-variable-per-declaration
761
- let x = new Float64Array ( 64 ) ,
762
- i ;
763
- for ( i = 0 ; i < 64 ; i ++ ) {
764
- x [ i ] = r [ i ] ;
765
- }
766
- for ( i = 0 ; i < 64 ; i ++ ) {
767
- r [ i ] = 0 ;
768
- }
769
- modL ( r , x ) ;
770
- } ;
771
-
772
709
export const pack = ( r , p ) => {
773
710
// tslint:disable-next-line:one-variable-per-declaration
774
711
const tx = gf ( ) ,
@@ -797,64 +734,6 @@ export const scalarmult = (p, q, s) => {
797
734
}
798
735
} ;
799
736
800
- export const scalarbase = ( p , s ) => {
801
- const q = [ gf ( ) , gf ( ) , gf ( ) , gf ( ) ] ;
802
- set25519 ( q [ 0 ] , X ) ;
803
- set25519 ( q [ 1 ] , Y ) ;
804
- set25519 ( q [ 2 ] , gf1 ) ;
805
- M ( q [ 3 ] , X , Y ) ;
806
- scalarmult ( p , q , s ) ;
807
- } ;
808
-
809
- export const unpackneg = ( r , p ) => {
810
- // tslint:disable-next-line:one-variable-per-declaration
811
- const t = gf ( ) ,
812
- chk = gf ( ) ,
813
- num = gf ( ) ,
814
- den = gf ( ) ,
815
- den2 = gf ( ) ,
816
- den4 = gf ( ) ,
817
- den6 = gf ( ) ;
818
-
819
- set25519 ( r [ 2 ] , gf1 ) ;
820
- unpack25519 ( r [ 1 ] , p ) ;
821
- S ( num , r [ 1 ] ) ;
822
- M ( den , num , D ) ;
823
- Z ( num , num , r [ 2 ] ) ;
824
- A ( den , r [ 2 ] , den ) ;
825
-
826
- S ( den2 , den ) ;
827
- S ( den4 , den2 ) ;
828
- M ( den6 , den4 , den2 ) ;
829
- M ( t , den6 , num ) ;
830
- M ( t , t , den ) ;
831
-
832
- pow2523 ( t , t ) ;
833
- M ( t , t , num ) ;
834
- M ( t , t , den ) ;
835
- M ( t , t , den ) ;
836
- M ( r [ 0 ] , t , den ) ;
837
-
838
- S ( chk , r [ 0 ] ) ;
839
- M ( chk , chk , den ) ;
840
- if ( neq25519 ( chk , num ) ) {
841
- M ( r [ 0 ] , r [ 0 ] , I ) ;
842
- }
843
-
844
- S ( chk , r [ 0 ] ) ;
845
- M ( chk , chk , den ) ;
846
- if ( neq25519 ( chk , num ) ) {
847
- return - 1 ;
848
- }
849
-
850
- if ( par25519 ( r [ 0 ] ) === ( p [ 31 ] >> 7 ) ) {
851
- Z ( r [ 0 ] , gf0 , r [ 0 ] ) ;
852
- }
853
-
854
- M ( r [ 3 ] , r [ 0 ] , r [ 1 ] ) ;
855
- return 0 ;
856
- } ;
857
-
858
737
export const unpack = ( r , p ) => {
859
738
// tslint:disable-next-line:one-variable-per-declaration
860
739
const t = gf ( ) ,
0 commit comments