Debian Codegraph @

cref/cref.go

raw symbols SCIP
1 // A C implementation of the Ristretto group based on the PandA library
2 // by Chuengsatiansup, Ribarski and Schwabe, which we use as a reference
3 // of our pure Go implementation.
4 // See also https://link.springer.com/chapter/10.1007/978-3-319-04873-4_14
5 package cref
6
7 // #include "cref.h"
8 import "C"
9
10 type Fe25519 C.fe25519
11 type GroupGe C.group_ge
12 type GroupScalar C.group_scalar
13
14 func (f *Fe25519) c() *C.fe25519 {
15 return (*C.fe25519)(f)
16 }
17
18 func (f *Fe25519) Unpack(buf *[32]byte) {
19 C.fe25519_unpack(f.c(), (*C.uchar)(&buf[0]))
20 }
21
22 func (f *Fe25519) Pack(buf *[32]byte) {
23 C.fe25519_pack((*C.uchar)(&buf[0]), f.c())
24 }
25
26 func (g *GroupGe) c() *C.group_ge {
27 return (*C.group_ge)(g)
28 }
29
30 func (g *GroupGe) Pack(buf *[32]byte) {
31 C.group_ge_pack((*C.uchar)(&buf[0]), g.c())
32 }
33
34 func (g *GroupGe) Unpack(buf *[32]byte) int {
35 return int(C.group_ge_unpack(g.c(), (*C.uchar)(&buf[0])))
36 }
37
38 func (g *GroupGe) Elligator(r0 *Fe25519) {
39 C.group_ge_elligator(g.c(), r0.c())
40 }
41
42 func (g *GroupGe) Neg(x *GroupGe) {
43 C.group_ge_negate(g.c(), x.c())
44 }
45
46 func (g *GroupGe) Add(x, y *GroupGe) {
47 C.group_ge_add(g.c(), x.c(), y.c())
48 }
49
50 func (g *GroupGe) Double(x *GroupGe) {
51 C.group_ge_double(g.c(), x.c())
52 }
53
54 func (g *GroupGe) ScalarMult(x *GroupGe, s *GroupScalar) {
55 C.group_ge_scalarmult(g.c(), x.c(), s.c())
56 }
57
58 func (g *GroupGe) X() *Fe25519 {
59 return (*Fe25519)(&g.c().x)
60 }
61
62 func (g *GroupGe) Y() *Fe25519 {
63 return (*Fe25519)(&g.c().y)
64 }
65
66 func (g *GroupGe) Z() *Fe25519 {
67 return (*Fe25519)(&g.c().z)
68 }
69
70 func (g *GroupGe) T() *Fe25519 {
71 return (*Fe25519)(&g.c().t)
72 }
73
74 func (s *GroupScalar) c() *C.group_scalar {
75 return (*C.group_scalar)(s)
76 }
77
78 func (s *GroupScalar) Unpack(buf *[32]byte) {
79 C.group_scalar_unpack(s.c(), (*C.uchar)(&buf[0]))
80 }
81
82 func (s *GroupScalar) Pack(buf *[32]byte) {
83 C.group_scalar_pack((*C.uchar)(&buf[0]), s.c())
84 }