2023-04-07 18:23:07 +00:00
|
|
|
//go:build (arm || arm64) && linux
|
|
|
|
// +build arm arm64
|
|
|
|
// +build linux
|
|
|
|
|
|
|
|
package link
|
|
|
|
|
|
|
|
import r "github.com/waku-org/go-zerokit-rln-arm/rln"
|
|
|
|
|
|
|
|
type RLNWrapper struct {
|
|
|
|
ffi *r.RLN
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func NewWithParams(depth int, wasm []byte, zkey []byte, verifKey []byte, treeConfig []byte) (*RLNWrapper, error) {
|
|
|
|
rln, err := r.NewWithParams(depth, wasm, zkey, verifKey, treeConfig)
|
2023-04-07 18:23:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &RLNWrapper{ffi: rln}, nil
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func New(depth int, config []byte) (*RLNWrapper, error) {
|
|
|
|
rln, err := r.New(uint(depth), config)
|
2023-04-07 18:23:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return &RLNWrapper{ffi: rln}, nil
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func (i RLNWrapper) SetTree(treeHeight uint) bool {
|
|
|
|
return i.ffi.SetTree(treeHeight)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) InitTreeWithLeaves(idcommitments []byte) bool {
|
|
|
|
return i.ffi.InitTreeWithLeaves(idcommitments)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) KeyGen() []byte {
|
|
|
|
return i.ffi.KeyGen()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) SeededKeyGen(seed []byte) []byte {
|
|
|
|
return i.ffi.SeededKeyGen(seed)
|
|
|
|
}
|
|
|
|
|
2023-04-07 18:23:07 +00:00
|
|
|
func (i RLNWrapper) ExtendedKeyGen() []byte {
|
|
|
|
return i.ffi.ExtendedKeyGen()
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func (i RLNWrapper) ExtendedSeededKeyGen(seed []byte) []byte {
|
|
|
|
return i.ffi.ExtendedSeededKeyGen(seed)
|
|
|
|
}
|
|
|
|
|
2023-04-07 18:23:07 +00:00
|
|
|
func (i RLNWrapper) Hash(input []byte) ([]byte, error) {
|
|
|
|
return i.ffi.Hash(input)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) PoseidonHash(input []byte) ([]byte, error) {
|
|
|
|
return i.ffi.PoseidonHash(input)
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func (i RLNWrapper) SetLeaf(index uint, idcommitment []byte) bool {
|
|
|
|
return i.ffi.SetLeaf(index, idcommitment)
|
|
|
|
}
|
|
|
|
|
2023-04-07 18:23:07 +00:00
|
|
|
func (i RLNWrapper) SetNextLeaf(idcommitment []byte) bool {
|
|
|
|
return i.ffi.SetNextLeaf(idcommitment)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) SetLeavesFrom(index uint, idcommitments []byte) bool {
|
|
|
|
return i.ffi.SetLeavesFrom(index, idcommitments)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) DeleteLeaf(index uint) bool {
|
|
|
|
return i.ffi.DeleteLeaf(index)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) GetRoot() ([]byte, error) {
|
|
|
|
return i.ffi.GetRoot()
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func (i RLNWrapper) GetLeaf(index uint) ([]byte, error) {
|
|
|
|
return i.ffi.GetLeaf(index)
|
|
|
|
}
|
|
|
|
|
2023-04-07 18:23:07 +00:00
|
|
|
func (i RLNWrapper) GenerateRLNProof(input []byte) ([]byte, error) {
|
|
|
|
return i.ffi.GenerateRLNProof(input)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) VerifyWithRoots(input []byte, roots []byte) (bool, error) {
|
|
|
|
return i.ffi.VerifyWithRoots(input, roots)
|
|
|
|
}
|
2023-08-22 10:32:01 +00:00
|
|
|
|
|
|
|
func (i RLNWrapper) AtomicOperation(index uint, leaves []byte, indices []byte) bool {
|
|
|
|
return i.ffi.AtomicOperation(index, leaves, indices)
|
|
|
|
}
|
|
|
|
|
2023-09-07 15:29:28 +00:00
|
|
|
func (i RLNWrapper) SeqAtomicOperation(leaves []byte, indices []byte) bool {
|
|
|
|
return i.ffi.SeqAtomicOperation(leaves, indices)
|
|
|
|
}
|
|
|
|
|
2023-08-22 10:32:01 +00:00
|
|
|
func (i RLNWrapper) RecoverIDSecret(proof1 []byte, proof2 []byte) ([]byte, error) {
|
|
|
|
return i.ffi.RecoverIDSecret(proof1, proof2)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) SetMetadata(metadata []byte) bool {
|
|
|
|
return i.ffi.SetMetadata(metadata)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) GetMetadata() ([]byte, error) {
|
|
|
|
return i.ffi.GetMetadata()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i RLNWrapper) Flush() bool {
|
|
|
|
return i.ffi.Flush()
|
|
|
|
}
|