@@ -193,7 +193,7 @@ public void valid() throws ZksnarkException {
193193 /**
194194 * KaAgree(sk,p)=[h_J*sk]p p: point, 32 bytes sk: 32 bytes result: 32 bytes
195195 */
196- public static class SaplingKaAgreeParams implements ValidParam {
196+ public static class KaAgreeParams implements ValidParam {
197197
198198 @ Setter
199199 @ Getter
@@ -205,7 +205,7 @@ public static class SaplingKaAgreeParams implements ValidParam {
205205 @ Getter
206206 private byte [] result ;
207207
208- public SaplingKaAgreeParams (byte [] p , byte [] sk , byte [] result ) throws ZksnarkException {
208+ public KaAgreeParams (byte [] p , byte [] sk , byte [] result ) throws ZksnarkException {
209209 this .p = p ;
210210 this .sk = sk ;
211211 this .result = result ;
@@ -224,7 +224,7 @@ public void valid() throws ZksnarkException {
224224 * Compute note commitment d: diversifier, 11 bytes pk_d: 32 bytes r: rcm, 32 bytes cm: note
225225 * commitment, 32 bytes
226226 */
227- public static class SaplingComputeCmParams implements ValidParam {
227+ public static class ComputeCmParams implements ValidParam {
228228
229229 @ Setter
230230 @ Getter
@@ -242,7 +242,7 @@ public static class SaplingComputeCmParams implements ValidParam {
242242 @ Getter
243243 private byte [] cm ;
244244
245- public SaplingComputeCmParams (byte [] d , byte [] pk_d , long value , byte [] r , byte [] cm )
245+ public ComputeCmParams (byte [] d , byte [] pk_d , long value , byte [] r , byte [] cm )
246246 throws ZksnarkException {
247247 this .d = d ;
248248 this .pk_d = pk_d ;
@@ -266,7 +266,7 @@ public void valid() throws ZksnarkException {
266266 * spendAuthSig.PulicKey, 32 bytes nk: to genarate nullifier, 32 bytes result: nullifier, 32
267267 * bytes
268268 */
269- public static class SaplingComputeNfParams implements ValidParam {
269+ public static class ComputeNfParams implements ValidParam {
270270
271271 @ Setter
272272 @ Getter
@@ -293,7 +293,7 @@ public static class SaplingComputeNfParams implements ValidParam {
293293 @ Getter
294294 private byte [] result ;
295295
296- public SaplingComputeNfParams (byte [] d , byte [] pk_d , long value , byte [] r , byte [] ak , byte [] nk ,
296+ public ComputeNfParams (byte [] d , byte [] pk_d , long value , byte [] r , byte [] ak , byte [] nk ,
297297 long position , byte [] result ) throws ZksnarkException {
298298 this .d = d ;
299299 this .pk_d = pk_d ;
@@ -320,7 +320,7 @@ public void valid() throws ZksnarkException {
320320 /**
321321 * diversifier: d, 11 bytes esk: 32 bytes result: return 32 bytes
322322 */
323- public static class SaplingKaDerivepublicParams implements ValidParam {
323+ public static class KaDerivepublicParams implements ValidParam {
324324
325325 @ Setter
326326 @ Getter
@@ -332,7 +332,7 @@ public static class SaplingKaDerivepublicParams implements ValidParam {
332332 @ Getter
333333 private byte [] result ;
334334
335- public SaplingKaDerivepublicParams (byte [] diversifier , byte [] esk , byte [] result )
335+ public KaDerivepublicParams (byte [] diversifier , byte [] esk , byte [] result )
336336 throws ZksnarkException {
337337 this .diversifier = diversifier ;
338338 this .esk = esk ;
@@ -354,7 +354,7 @@ public void valid() throws ZksnarkException {
354354 * voucherPath[0]=0x20, voucherPath[1+i*33]=0x20,i=0,1,...31. cv: value commitment, 32 bytes rk:
355355 * spendAuthSig.randomizePublicKey 32 bytes zkproof: spend proof, 192 bytes
356356 */
357- public static class SaplingSpendProofParams implements ValidParam {
357+ public static class SpendProofParams implements ValidParam {
358358
359359 @ Setter
360360 @ Getter
@@ -393,7 +393,7 @@ public static class SaplingSpendProofParams implements ValidParam {
393393 @ Getter
394394 private byte [] zkproof ;
395395
396- public SaplingSpendProofParams (Pointer ctx , byte [] ak , byte [] nsk , byte [] d , byte [] r ,
396+ public SpendProofParams (Pointer ctx , byte [] ak , byte [] nsk , byte [] d , byte [] r ,
397397 byte [] alpha , long value , byte [] anchor , byte [] voucherPath , byte [] cv , byte [] rk ,
398398 byte [] zkproof ) throws ZksnarkException {
399399 this .ctx = ctx ;
@@ -431,7 +431,7 @@ public void valid() throws ZksnarkException {
431431 * esk: 32 bytes d: 11 bytes pk_d: 32 bytes r: rcm, 32 bytes cv: value commitment, 32 bytes
432432 * zkproof: receive proof, 192 bytes
433433 */
434- public static class SaplingOutputProofParams implements ValidParam {
434+ public static class OutputProofParams implements ValidParam {
435435
436436 @ Setter
437437 @ Getter
@@ -458,7 +458,7 @@ public static class SaplingOutputProofParams implements ValidParam {
458458 @ Getter
459459 private byte [] zkproof ;
460460
461- public SaplingOutputProofParams (Pointer ctx , byte [] esk , byte [] d , byte [] pk_d , byte [] r ,
461+ public OutputProofParams (Pointer ctx , byte [] esk , byte [] d , byte [] pk_d , byte [] r ,
462462 long value , byte [] cv , byte [] zkproof ) throws ZksnarkException {
463463 this .ctx = ctx ;
464464 this .esk = esk ;
@@ -487,7 +487,7 @@ public void valid() throws ZksnarkException {
487487 * ask: the spend authorizing key, 32 bytes alpha: random number, 32 bytes sigHash: sha256 of
488488 * transaction, 32 bytes result: spendAuthSig, 64 bytes
489489 */
490- public static class SaplingSpendSigParams implements ValidParam {
490+ public static class SpendSigParams implements ValidParam {
491491
492492 @ Setter
493493 @ Getter
@@ -502,7 +502,7 @@ public static class SaplingSpendSigParams implements ValidParam {
502502 @ Getter
503503 private byte [] result ;
504504
505- public SaplingSpendSigParams (byte [] ask , byte [] alpha , byte [] sigHash , byte [] result )
505+ public SpendSigParams (byte [] ask , byte [] alpha , byte [] sigHash , byte [] result )
506506 throws ZksnarkException {
507507 this .ask = ask ;
508508 this .alpha = alpha ;
@@ -524,7 +524,7 @@ public void valid() throws ZksnarkException {
524524 * Generate binding signature sighash: sha256 of transaction,32 bytes result: binding signature,
525525 * 64 bytes
526526 */
527- public static class SaplingBindingSigParams implements ValidParam {
527+ public static class BindingSigParams implements ValidParam {
528528
529529 @ Setter
530530 @ Getter
@@ -539,7 +539,7 @@ public static class SaplingBindingSigParams implements ValidParam {
539539 @ Getter
540540 private byte [] result ;
541541
542- public SaplingBindingSigParams (Pointer ctx , long valueBalance , byte [] sighash , byte [] result )
542+ public BindingSigParams (Pointer ctx , long valueBalance , byte [] sighash , byte [] result )
543543 throws ZksnarkException {
544544 this .ctx = ctx ;
545545 this .valueBalance = valueBalance ;
@@ -561,7 +561,7 @@ public void valid() throws ZksnarkException {
561561 * spendAuthSig.randomizePublicKey, 32 bytes zkproof: spend proof, 192 bytes spendAuthSig: 64
562562 * bytes sighashValue: sha256 of transaction, 32 bytes
563563 */
564- public static class SaplingCheckSpendParams implements ValidParam {
564+ public static class CheckSpendParams implements ValidParam {
565565
566566 @ Setter
567567 @ Getter
@@ -588,7 +588,7 @@ public static class SaplingCheckSpendParams implements ValidParam {
588588 @ Getter
589589 private byte [] sighashValue ;
590590
591- public SaplingCheckSpendParams (Pointer ctx , byte [] cv , byte [] anchor , byte [] nullifier ,
591+ public CheckSpendParams (Pointer ctx , byte [] cv , byte [] anchor , byte [] nullifier ,
592592 byte [] rk , byte [] zkproof , byte [] spendAuthSig , byte [] sighashValue )
593593 throws ZksnarkException {
594594 this .ctx = ctx ;
@@ -613,13 +613,33 @@ public void valid() throws ZksnarkException {
613613 validParamLength (spendAuthSig , 64 );
614614 valid32Params (sighashValue );
615615 }
616+
617+ public static CheckSpendParams decode (Pointer ctx , byte [] data , byte [] sigHashValue )
618+ throws ZksnarkException {
619+ byte [] cv = new byte [32 ];
620+ byte [] anchor = new byte [32 ];
621+ byte [] nullifier = new byte [32 ];
622+ byte [] rk = new byte [32 ];
623+ byte [] zkproof = new byte [192 ];
624+ byte [] spendAuthSig = new byte [64 ];
625+
626+ System .arraycopy (data , 0 , cv , 0 , 32 );
627+ System .arraycopy (data , 32 , anchor , 0 , 32 );
628+ System .arraycopy (data , 64 , nullifier , 0 , 32 );
629+ System .arraycopy (data , 96 , rk , 0 , 32 );
630+ System .arraycopy (data , 128 , zkproof , 0 , 192 );
631+ System .arraycopy (data , 320 , spendAuthSig , 0 , 64 );
632+
633+ return new CheckSpendParams (ctx , cv , anchor , nullifier , rk , zkproof , spendAuthSig ,
634+ sigHashValue );
635+ }
616636 }
617637
618638 /**
619639 * cv: value commitments, 32 bytes cm: note commitment, 32 bytes ephemeralKey: 32 bytes zkproof:
620640 * 192 bytes
621641 */
622- public static class SaplingCheckOutputParams implements ValidParam {
642+ public static class CheckOutputParams implements ValidParam {
623643
624644 @ Setter
625645 @ Getter
@@ -637,7 +657,7 @@ public static class SaplingCheckOutputParams implements ValidParam {
637657 @ Getter
638658 private byte [] zkproof ;
639659
640- public SaplingCheckOutputParams (Pointer ctx , byte [] cv , byte [] cm , byte [] ephemeralKey ,
660+ public CheckOutputParams (Pointer ctx , byte [] cv , byte [] cm , byte [] ephemeralKey ,
641661 byte [] zkproof ) throws ZksnarkException {
642662 this .ctx = ctx ;
643663 this .cv = cv ;
@@ -660,7 +680,7 @@ public void valid() throws ZksnarkException {
660680 /**
661681 * bindingSig: 64 bytes sighashValue: sha256 of transaction,32 bytes
662682 */
663- public static class SaplingFinalCheckParams implements ValidParam {
683+ public static class FinalCheckParams implements ValidParam {
664684
665685 @ Setter
666686 @ Getter
@@ -675,7 +695,7 @@ public static class SaplingFinalCheckParams implements ValidParam {
675695 @ Getter
676696 private byte [] sighashValue ;
677697
678- public SaplingFinalCheckParams (Pointer ctx , long valueBalance , byte [] bindingSig ,
698+ public FinalCheckParams (Pointer ctx , long valueBalance , byte [] bindingSig ,
679699 byte [] sighashValue ) throws ZksnarkException {
680700 this .ctx = ctx ;
681701 this .valueBalance = valueBalance ;
0 commit comments