zuse: cleanup in schnorr
--
|%
::
- ++ sign
+ ++ sign :: schnorr signature
:: ~/ %sosi
|= [sk=@I m=@I a=@I]
^- @J
=/ t
%+ mix
(flip 32 d)
- (tagged-hash 'BIP0340/aux' [32 (flip 32 a)])
+ %+ tagged-hash 'BIP0340/aux'
+ [32 (flip 32 a)]
=/ rand
%+ tagged-hash 'BIP0340/nonce'
- =/ pin
- (can 8 ~[[1 t] [1 (flip 32 x.pp)] [1 (flip 32 m)]])
- [96 pin]
+ :- 96
+ %+ can 8
+ :~ [1 t]
+ [1 (flip 32 x.pp)]
+ [1 (flip 32 m)]
+ ==
=/ kp (mod (flip 32 rand) n.domain.c)
=/ rr (mul-point-scalar g.domain.c kp)
=/ k
:_ n.domain.c
%+ flip 32
%+ tagged-hash 'BIP0340/challenge'
- =/ pin
+ :- 96
%+ can 8
:~ [1 (flip 32 x.rr)]
[1 (flip 32 x.pp)]
[1 (flip 32 m)]
==
- [96 pin]
=/ sig
%+ flip 64
%^ cat 8
?> (verify x.pp m sig)
sig
::
- ++ verify
+ ++ verify :: schnorr verify
:: ~/ %sove
|= [pk=@I m=@I sig=@J]
^- ?
(mul-point-scalar g.domain.c s)
=/ bb
(mul-point-scalar pp (sub n.domain.c e))
- ?: &(=(x.aa x.bb) !=(y.aa y.bb))
+ ?: &(=(x.aa x.bb) !=(y.aa y.bb)) :: check infinity
%.n
=/ rr (add-points aa bb)
- ~& :- m+`@ux`m
- :- pk+`@ux`pk
- :- sig+`@ux`sig
- :- pp+`[@ux @ux]`pp
- :- r+`@ux`r
- :- s+`@ux`s
- :- e+`@ux`e
- rr+`[@ux @ux]`rr
?. =(0 (mod y.rr 2))
%.n
=(r x.rr)
