@@ -133,25 +133,21 @@ void librustzcash_merkle_hash(int depth, byte[] a, byte[] b, byte[] result
133133 void librustzcash_to_scalar (byte [] input , byte [] result );
134134 }
135135
136- public static void librustzcashZip32XskMaster (Zip32XskMasterParams params )
137- throws ZksnarkException {
136+ public static void librustzcashZip32XskMaster (Zip32XskMasterParams params ) {
138137 INSTANCE .librustzcash_zip32_xsk_master (params .getData (), params .getSize (), params .getM_bytes ());
139138 }
140139
141- public static void librustzcashInitZksnarkParams (InitZksnarkParams params )
142- throws ZksnarkException {
140+ public static void librustzcashInitZksnarkParams (InitZksnarkParams params ) {
143141 INSTANCE .librustzcash_init_zksnark_params (params .getSpend_path (), params .getSpend_path_len (),
144142 params .getSpend_hash (), params .getOutput_path (), params .getOutput_path_len (),
145143 params .getOutput_hash ());
146144 }
147145
148- public static void librustzcashZip32XskDerive (Zip32XskDeriveParams params )
149- throws ZksnarkException {
146+ public static void librustzcashZip32XskDerive (Zip32XskDeriveParams params ) {
150147 INSTANCE .librustzcash_zip32_xsk_derive (params .getData (), params .getSize (), params .getM_bytes ());
151148 }
152149
153- public static boolean librustzcashZip32XfvkAddress (Zip32XfvkAddressParams params )
154- throws ZksnarkException {
150+ public static boolean librustzcashZip32XfvkAddress (Zip32XfvkAddressParams params ) {
155151 return INSTANCE .librustzcash_zip32_xfvk_address (params .getXfvk (), params .getJ (),
156152 params .getJ_ret (), params .getAddr_ret ());
157153 }
@@ -351,5 +347,73 @@ private static String getLibrary(String name) {
351347 return fileOut .getAbsolutePath ();
352348 }
353349
350+ public static void main (String [] args ) throws ZksnarkException {
351+ byte [] d = {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 };
352+ //byte[] d ={};
353+ //byte[] pk_d = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
354+ byte [] ivk = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ,
355+ 9 , 10 , 11 , 12 , 13 , 14 , 15 };
356+ byte [] pk_d = new byte [32 ];
357+ long value = 1 ;
358+ byte [] r = {(byte ) 0xb7 , 0x2c , (byte ) 0xf7 , (byte ) 0xd6 , 0x5e , 0x0e , (byte ) 0x97 , (byte ) 0xd0 ,
359+ (byte ) 0x82 , 0x10 , (byte ) 0xc8 , (byte ) 0xcc , (byte ) 0x93 , 0x20 , 0x68 , (byte ) 0xa6 , 0x00 ,
360+ 0x3b , 0x34 , 0x01 , 0x01 , 0x3b , 0x67 , 0x06 , (byte ) 0xa9 , (byte ) 0xaf , 0x33 , 0x65 , (byte ) 0xea ,
361+ (byte ) 0xb4 , 0x7d , 0x0e };
362+ byte [] cm = new byte [32 ];
363+ boolean check_d = librustzcashCheckDiversifier (d );
364+ System .out .println ("d is " + check_d );
365+
366+ ivk [31 ] = (byte ) 0x10 ;
367+ boolean check_pkd = librustzcashIvkToPkd (new IvkToPkdParams (ivk , d , pk_d ));
368+ System .out .println ("pk_d is\n " );
369+ for (int j = 0 ; j < 32 ; j ++) {
370+ System .out .printf ("%x " , pk_d [j ]);
371+ if ((j + 1 ) % 16 == 0 ) {
372+ System .out .printf ("\n " );
373+ }
374+ }
375+
376+ boolean res = librustzcashSaplingComputeCm (new SaplingComputeCmParams (d , pk_d , value , r , cm ));
377+ System .out .println ("cm is" + res );
378+
379+ //check range of alpha
380+ byte [] ask = {(byte ) 0xb7 , 0x2c , (byte ) 0xf7 , (byte ) 0xd6 , 0x5e , 0x0e , (byte ) 0x97 , (byte ) 0xd0 ,
381+ (byte ) 0x82 , 0x10 , (byte ) 0xc8 , (byte ) 0xcc , (byte ) 0x93 , 0x20 , 0x68 , (byte ) 0xa6 , 0x00 ,
382+ 0x3b , 0x34 , 0x01 , 0x01 , 0x3b , 0x67 , 0x06 , (byte ) 0xa9 , (byte ) 0xaf , 0x33 , 0x65 , (byte ) 0xea ,
383+ (byte ) 0xb4 , 0x7d , 0x0e };
384+ byte [] alpha = {(byte ) 0xb6 , 0x2c , (byte ) 0xf7 , (byte ) 0xd6 , 0x5e , 0x0e , (byte ) 0x97 ,
385+ (byte ) 0xd0 , (byte ) 0x82 , 0x10 , (byte ) 0xc8 , (byte ) 0xcc , (byte ) 0x93 , 0x20 , 0x68 ,
386+ (byte ) 0xa6 , 0x00 , 0x3b , 0x34 , 0x01 , 0x01 , 0x3b , 0x67 , 0x06 , (byte ) 0xa9 , (byte ) 0xaf , 0x33 ,
387+ 0x65 , (byte ) 0xea , (byte ) 0xb4 , 0x7d , 0x0e };
388+ byte [] sighash = {0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 ,
389+ 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 };
390+ byte [] sigRes = new byte [64 ];
391+ boolean boolSigRes = librustzcashSaplingSpendSig (
392+ new SaplingSpendSigParams (ask , alpha , sighash , sigRes ));
393+ System .out .println ("sig result " + boolSigRes );
394+
395+ byte [] nsk = {(byte ) 0xb6 , 0x2c , (byte ) 0xf7 , (byte ) 0xd6 , 0x5e , 0x0e , (byte ) 0x97 , (byte ) 0xd0 ,
396+ (byte ) 0x82 , 0x10 , (byte ) 0xc8 , (byte ) 0xcc , (byte ) 0x93 , 0x20 , 0x68 , (byte ) 0xa6 , 0x00 ,
397+ 0x3b , 0x34 , 0x01 , 0x01 , 0x3b , 0x67 , 0x06 , (byte ) 0xa9 , (byte ) 0xaf , 0x33 , 0x65 , (byte ) 0xea ,
398+ (byte ) 0xb4 , 0x7d , 0x0e };
399+ byte [] nk = new byte [32 ];
400+ nk = librustzcashNskToNk (nsk );
401+
402+ for (int j = 0 ; j < 32 ; j ++) {
403+ System .out .printf ("%x " , nk [j ]);
404+ if ((j + 1 ) % 16 == 0 ) {
405+ System .out .printf ("\n " );
406+ }
407+ }
408+
409+ Pointer ctx = librustzcashSaplingProvingCtxInit ();
410+ byte [] resbindSig = new byte [64 ];
411+ boolean boolBindSig = librustzcashSaplingBindingSig (
412+ new SaplingBindingSigParams (ctx , value , null , resbindSig ));
413+ System .out .println ("binding sig result " + boolBindSig );
414+
415+
416+ }
417+
354418
355419}
0 commit comments