Commit graph

200 commits

Author SHA1 Message Date
Filippo Valsorda abc8c5a4ea internal/radix51: make reduction an invariant and unexport Reduce
Now every operation returns a light-reduced value, so the reduction is
an invariant, and there's no need to ever explicitly call Reduce.

Safety!
2019-03-30 22:12:39 -04:00
Filippo Valsorda 4fd198dbf1 internal/radix51: actually apply go:noescape 2019-03-30 22:12:39 -04:00
Dimitris Apostolou 18c803cb82 all: fix typos 2019-03-30 21:29:01 -04:00
George Tankersley bbfe05949b internal/radix51: test field encoding roundtrip with fixed vectors 2019-03-30 21:23:15 -04:00
Filippo Valsorda c428b185ea internal/radix51: rename AppendBytes to Bytes 2019-03-30 21:23:15 -04:00
Filippo Valsorda c59bc1a95a internal/radix51: rewrite FromBytes and AppendBytes with encoding/binary 2019-03-30 21:23:15 -04:00
Filippo Valsorda 57c0cd5f37 internal/radix51: add docs and some light readability refactors 2019-03-30 21:23:15 -04:00
Filippo Valsorda cb1b734137 internal/radix51: remove unused (and a bit broken) SetInt
It would return an invalid element if the input was greater than 2^54 - 1.
2019-03-30 21:23:15 -04:00
Filippo Valsorda beb8abdfef internal/radix51: refactor ToBig and FromBig 2019-03-30 21:23:15 -04:00
Filippo Valsorda 87c0a53713 internal/radix51: replace ToBytes with AppendBytes 2019-03-30 21:23:15 -04:00
George Tankersley b7e1e4501b internal/radix51: fix aliasing bug in CondNeg (#21) 2019-03-24 20:32:49 -04:00
Filippo Valsorda ed3748da75 internal/radix51: actually, uhm, check the result of TestAliasing 2019-03-15 17:37:41 -04:00
George Tankersley ec0e293fad radix51: change API of FromBytes and ToBytes to use slices 2019-03-02 21:40:51 -05:00
Filippo Valsorda 29f6815f8e internal/radix51: test all combinations of argument and receiver aliasing 2019-03-02 19:44:59 -05:00
Henry de Valence cd53d90f4b internal/radix51: add property-based tests that multiplication distributes over addition
Closes #12
2019-03-02 19:44:59 -05:00
George Tankersley c3bc45f65d radix51: use go1.12 intrinsics for 128-bit multiplications 2019-02-19 18:36:55 -05:00
Filippo Valsorda 7e7043eb07 internal/radix51: define a mask64Bits constant 2019-01-28 10:53:34 -05:00
Filippo Valsorda 4fdd06d7f4 internal/group: set Z to 1, not 0 in FromAffine 2019-01-28 10:53:34 -05:00
Filippo Valsorda ffa7be7c16 internal/group: fix typo 2019-01-28 10:53:34 -05:00
Filippo Valsorda 1f452ac69a internal/group: derive twoD from D 2019-01-28 10:53:34 -05:00
Filippo Valsorda 2424c7866c internal/radix51: add MinusOne 2019-01-28 10:53:34 -05:00
Filippo Valsorda 76978fc43f internal/group: make conversion APIs caller-allocated 2019-01-28 10:53:34 -05:00
Filippo Valsorda d17d202e4a internal/group: rewrite DoubleZ1 because stack is cheaper than mental state 2019-01-28 10:53:34 -05:00
Filippo Valsorda 72b97c18f3 internal: make all APIs chainable 2019-01-28 10:53:34 -05:00
Filippo Valsorda 993d979188 internal/radix51: make all APIs not consider the receiver an input 2019-01-28 10:53:34 -05:00
Filippo Valsorda b2a1d7d5cb all: refactor field API to be methods based 2019-01-28 10:53:34 -05:00
Filippo Valsorda 0d9f09a5c0 Import gtank/ed25519#8 and refactor on top of it 2019-01-26 22:20:45 -05:00
Filippo Valsorda 6a64a071b1 Update gtank/ed25519 code to fe6e0954e0ad069aa87da23607c1e05a3151d0a2
Our Ristretto-agnostic field operations are now upstreamed, so we can
drop the internal package.
2019-01-21 18:13:23 -05:00
Filippo Valsorda cdf9b90eef internal/radix51: add constant time field operations 2019-01-21 17:58:03 -05:00
Filippo Valsorda e490a4880a internal/radix51: remove FeEqual
It does not normalize the representative before comparing them so it
will have false negatives.
2019-01-21 17:58:03 -05:00
Filippo Valsorda 2de114c75b internal/radix51: remove FeCSwap
It's unused and it does not do what it says in the docs.
2019-01-21 17:58:03 -05:00
Filippo Valsorda 3bb3886d1c Replace x/crypto/ed25519 code with github.com/gtank/ed25519
Code pulled from commit 0a030f62c035e01c406d2d85a69daa05894d7e11 with
FeEqual and FeCSwap removed.
2019-01-21 17:43:47 -05:00
George Tankersley e184ea4552 implement SQRT_RATIO_M1 2019-01-20 17:59:28 -05:00
Filippo Valsorda 318a0f8593 Refactor const.go 2019-01-20 17:36:31 -05:00
Filippo Valsorda 268ae6be59 Selectively expose types and functions from the inner x/crypto implementation 2019-01-20 17:32:31 -05:00
George Tankersley e93531adad internal: initialize Ristretto constants 2019-01-20 16:53:02 -05:00
Filippo Valsorda f963b4ec88 Add constant time field operations 2019-01-20 16:52:53 -05:00
Filippo Valsorda f1ea30515a Add FeEqual and feFromBig 2019-01-20 16:33:45 -05:00
George Tankersley 3db329037d initial import from x/crypto ff983b9c42bc9fbf91556e191cc8efb585c16908 2019-01-20 15:44:03 -05:00
George Tankersley 08b80c1299 make things more generally presentable 2017-07-25 16:24:16 -07:00
George Tankersley 2178536a77 Cache the field representation of d 2017-07-25 16:23:20 -07:00
George Tankersley 4135059a2f Remove 32-bit code and update license.
The assembly is faster on target amd64 platforms.
2017-07-25 16:23:20 -07:00
George Tankersley 5d95cb3738 Use Bits() for FeToBig.
This doesn't help quite as much as it does with FeFromBig, because
FeToBig runtime is dominated by the reduction step. Still helps though.
2017-07-25 16:23:19 -07:00
George Tankersley 146e33c08a Implement ScalarMult using Montgomery pattern and dedicated
extended-coordinates doubling. This will be slow.
2017-07-25 16:23:19 -07:00
George Tankersley 12a673a063 use faster FeFromBig & a horrible assortment of other random changes 2017-07-25 16:23:19 -07:00
George Tankersley 901f40ca96 group logic WIP 2017-07-25 16:23:19 -07:00
George Tankersley a9c89cdd10 add equality for field elements 2017-07-25 16:23:19 -07:00
George Tankersley 214873b8b2 Add radix51 FieldElement implementation
This contains both a pure Go and an amd64 assembly implementation of
operations over GF(2^255-19) using radix 2^51. This results in notable
speedups when using the assembly, but doesn't help much in pure Go -
most of the possible gains are lost to the lack of widening multiply for
64 bit integers.
2017-07-25 16:23:19 -07:00
George Tankersley 97ef82cb67 Add LICENSE 2017-07-25 16:23:19 -07:00
George Tankersley 8fd5caec47 Implement an elliptic.Curve for ed25519 2017-07-25 16:23:19 -07:00