feat: expose additional zerokit functions
This commit is contained in:
parent
df71229905
commit
75151c168b
6
go.mod
6
go.mod
|
@ -4,9 +4,9 @@ go 1.18
|
|||
|
||||
require (
|
||||
github.com/stretchr/testify v1.7.2
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230731180145-6df4912fe348
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230731180026-8704c2036d2b
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230731175926-d7831a9c95e5
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230801143206-7859920c65ec
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230801152407-8101ff87ee0a
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230801140722-0a4e68d0b8f5
|
||||
)
|
||||
|
||||
require (
|
||||
|
|
26
go.sum
26
go.sum
|
@ -13,26 +13,12 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331223042-3d24f0c813c3 h1:9V9Za2c8vaWM2ta/hrLibqUQw/KRgdZQdKejn/Q9exo=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331223042-3d24f0c813c3/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327 h1:Q5XQqo+PEmvrybT8D7BEsKCwIYDi80s+00Q49cfm9Gs=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230331231302-258cacb91327/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230517215159-cea56434b07a h1:YnpxsRnmQlFwouAdgtj95L/az32rlQ1Jtjx08CVx8tc=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230517215159-cea56434b07a/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230731180145-6df4912fe348 h1:PJC92jv0H3KX0ixVM//ferWlQUnVY1S4AtF3j5e0aOg=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230731180145-6df4912fe348/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d h1:Kcg85Y2xGU6hqZ/kMfkLQF2jAog8vt+tw1/VNidzNtE=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230331223149-f90e66aebb0d/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230517214322-89b514ad7697 h1:ogFZsxT02kIbo5qHmGBiYPLmfduFVNJYKfz0ozQxI5E=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230517214322-89b514ad7697/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230731180026-8704c2036d2b h1:N87rp2TFcl/76HWdfV5f26Qc1QbtrDbs36QcPiNohvU=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230731180026-8704c2036d2b/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9 h1:u+YUlWDltHiK5upSb7M6mStc84zdc4vTCNNOz7R5RaY=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230331181847-cba74520bae9/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230517190629-6d0c983d1080 h1:AO3Sv0ECsxGKdSUOuC4cfqVYtyjXZcKKwrY8lqQk+3g=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230517190629-6d0c983d1080/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230731175926-d7831a9c95e5 h1:yOvPC8M5XoTppHx9kgMfFOaK+k5+TWuQiY+YVBcgRdI=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230731175926-d7831a9c95e5/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230801143206-7859920c65ec h1:CYLH5FirJVwkKtYB0+8KqjZMCnd5OILuDzZ7Hk2vnGA=
|
||||
github.com/waku-org/go-zerokit-rln-apple v0.0.0-20230801143206-7859920c65ec/go.mod h1:KYykqtdApHVYZ3G0spwMnoxc5jH5eI3jyO9SwsSfi48=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230801152407-8101ff87ee0a h1:10cre+P76QvnLeyeCVAM8WDbUCri/y5xY3LtwI9Y5DE=
|
||||
github.com/waku-org/go-zerokit-rln-arm v0.0.0-20230801152407-8101ff87ee0a/go.mod h1:7cSGUoGVIla1IpnChrLbkVjkYgdOcr7rcifEfh4ReR4=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230801140722-0a4e68d0b8f5 h1:GseAHwGMixJ2zlY1kFYr3z1Ts0dREIYbgW4yIji9Ksw=
|
||||
github.com/waku-org/go-zerokit-rln-x86_64 v0.0.0-20230801140722-0a4e68d0b8f5/go.mod h1:+LeEYoW5/uBUTVjtBGLEVCUe9mOYAlu5ZPkIxLOSr5Y=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
|
|
|
@ -27,10 +27,30 @@ func NewWithFolder(depth int, resourcesFolderPath string) (*RLNWrapper, error) {
|
|||
return &RLNWrapper{ffi: rln}, nil
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) ExtendedKeyGen() []byte {
|
||||
return i.ffi.ExtendedKeyGen()
|
||||
}
|
||||
|
||||
func (i RLNWrapper) ExtendedSeededKeyGen(seed []byte) []byte {
|
||||
return i.ffi.ExtendedSeededKeyGen(seed)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) Hash(input []byte) ([]byte, error) {
|
||||
return i.ffi.Hash(input)
|
||||
}
|
||||
|
@ -39,6 +59,10 @@ func (i RLNWrapper) PoseidonHash(input []byte) ([]byte, error) {
|
|||
return i.ffi.PoseidonHash(input)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) SetLeaf(index uint, idcommitment []byte) bool {
|
||||
return i.ffi.SetLeaf(index, idcommitment)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) SetNextLeaf(idcommitment []byte) bool {
|
||||
return i.ffi.SetNextLeaf(idcommitment)
|
||||
}
|
||||
|
@ -70,3 +94,15 @@ func (i RLNWrapper) VerifyWithRoots(input []byte, roots []byte) (bool, error) {
|
|||
func (i RLNWrapper) AtomicOperation(index uint, leaves []byte, indices []byte) bool {
|
||||
return i.ffi.AtomicOperation(index, leaves, indices)
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -26,10 +26,30 @@ func NewWithFolder(depth int, resourcesFolderPath string) (*RLNWrapper, error) {
|
|||
return &RLNWrapper{ffi: rln}, nil
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) ExtendedKeyGen() []byte {
|
||||
return i.ffi.ExtendedKeyGen()
|
||||
}
|
||||
|
||||
func (i RLNWrapper) ExtendedSeededKeyGen(seed []byte) []byte {
|
||||
return i.ffi.ExtendedSeededKeyGen(seed)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) Hash(input []byte) ([]byte, error) {
|
||||
return i.ffi.Hash(input)
|
||||
}
|
||||
|
@ -38,6 +58,10 @@ func (i RLNWrapper) PoseidonHash(input []byte) ([]byte, error) {
|
|||
return i.ffi.PoseidonHash(input)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) SetLeaf(index uint, idcommitment []byte) bool {
|
||||
return i.ffi.SetLeaf(index, idcommitment)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) SetNextLeaf(idcommitment []byte) bool {
|
||||
return i.ffi.SetNextLeaf(idcommitment)
|
||||
}
|
||||
|
@ -69,3 +93,15 @@ func (i RLNWrapper) VerifyWithRoots(input []byte, roots []byte) (bool, error) {
|
|||
func (i RLNWrapper) AtomicOperation(index uint, leaves []byte, indices []byte) bool {
|
||||
return i.ffi.AtomicOperation(index, leaves, indices)
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
|
@ -27,10 +27,30 @@ func NewWithFolder(depth int, resourcesFolderPath string) (*RLNWrapper, error) {
|
|||
return &RLNWrapper{ffi: rln}, nil
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) ExtendedKeyGen() []byte {
|
||||
return i.ffi.ExtendedKeyGen()
|
||||
}
|
||||
|
||||
func (i RLNWrapper) ExtendedSeededKeyGen(seed []byte) []byte {
|
||||
return i.ffi.ExtendedSeededKeyGen(seed)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) Hash(input []byte) ([]byte, error) {
|
||||
return i.ffi.Hash(input)
|
||||
}
|
||||
|
@ -39,6 +59,10 @@ func (i RLNWrapper) PoseidonHash(input []byte) ([]byte, error) {
|
|||
return i.ffi.PoseidonHash(input)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) SetLeaf(index uint, idcommitment []byte) bool {
|
||||
return i.ffi.SetLeaf(index, idcommitment)
|
||||
}
|
||||
|
||||
func (i RLNWrapper) SetNextLeaf(idcommitment []byte) bool {
|
||||
return i.ffi.SetNextLeaf(idcommitment)
|
||||
}
|
||||
|
@ -70,3 +94,15 @@ func (i RLNWrapper) VerifyWithRoots(input []byte, roots []byte) (bool, error) {
|
|||
func (i RLNWrapper) AtomicOperation(index uint, leaves []byte, indices []byte) bool {
|
||||
return i.ffi.AtomicOperation(index, leaves, indices)
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,119 +1,119 @@
|
|||
{
|
||||
"protocol": "groth16",
|
||||
"curve": "bn128",
|
||||
"nPublic": 6,
|
||||
"vk_alpha_1": [
|
||||
"20124996762962216725442980738609010303800849578410091356605067053491763969391",
|
||||
"9118593021526896828671519912099489027245924097793322973632351264852174143923",
|
||||
"1"
|
||||
],
|
||||
"vk_beta_2": [
|
||||
[
|
||||
"4693952934005375501364248788849686435240706020501681709396105298107971354382",
|
||||
"14346958885444710485362620645446987998958218205939139994511461437152241966681"
|
||||
],
|
||||
[
|
||||
"16851772916911573982706166384196538392731905827088356034885868448550849804972",
|
||||
"823612331030938060799959717749043047845343400798220427319188951998582076532"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0"
|
||||
]
|
||||
],
|
||||
"vk_gamma_2": [
|
||||
[
|
||||
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
||||
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
|
||||
],
|
||||
[
|
||||
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
||||
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0"
|
||||
]
|
||||
],
|
||||
"vk_delta_2": [
|
||||
[
|
||||
"8353516066399360694538747105302262515182301251524941126222712285088022964076",
|
||||
"9329524012539638256356482961742014315122377605267454801030953882967973561832"
|
||||
],
|
||||
[
|
||||
"16805391589556134376869247619848130874761233086443465978238468412168162326401",
|
||||
"10111259694977636294287802909665108497237922060047080343914303287629927847739"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0"
|
||||
]
|
||||
],
|
||||
"vk_alphabeta_12": [
|
||||
[
|
||||
[
|
||||
"12608968655665301215455851857466367636344427685631271961542642719683786103711",
|
||||
"9849575605876329747382930567422916152871921500826003490242628251047652318086"
|
||||
],
|
||||
[
|
||||
"6322029441245076030714726551623552073612922718416871603535535085523083939021",
|
||||
"8700115492541474338049149013125102281865518624059015445617546140629435818912"
|
||||
],
|
||||
[
|
||||
"10674973475340072635573101639867487770811074181475255667220644196793546640210",
|
||||
"2926286967251299230490668407790788696102889214647256022788211245826267484824"
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
"9660441540778523475944706619139394922744328902833875392144658911530830074820",
|
||||
"19548113127774514328631808547691096362144426239827206966690021428110281506546"
|
||||
],
|
||||
[
|
||||
"1870837942477655969123169532603615788122896469891695773961478956740992497097",
|
||||
"12536105729661705698805725105036536744930776470051238187456307227425796690780"
|
||||
],
|
||||
[
|
||||
"21811903352654147452884857281720047789720483752548991551595462057142824037334",
|
||||
"19021616763967199151052893283384285352200445499680068407023236283004353578353"
|
||||
]
|
||||
]
|
||||
],
|
||||
"IC": [
|
||||
[
|
||||
"11992897507809711711025355300535923222599547639134311050809253678876341466909",
|
||||
"17181525095924075896332561978747020491074338784673526378866503154966799128110",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"17018665030246167677911144513385572506766200776123272044534328594850561667818",
|
||||
"18601114175490465275436712413925513066546725461375425769709566180981674884464",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"18799470100699658367834559797874857804183288553462108031963980039244731716542",
|
||||
"13064227487174191981628537974951887429496059857753101852163607049188825592007",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"17432501889058124609368103715904104425610382063762621017593209214189134571156",
|
||||
"13406815149699834788256141097399354592751313348962590382887503595131085938635",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"10320964835612716439094703312987075811498239445882526576970512041988148264481",
|
||||
"9024164961646353611176283204118089412001502110138072989569118393359029324867",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"718355081067365548229685160476620267257521491773976402837645005858953849298",
|
||||
"14635482993933988261008156660773180150752190597753512086153001683711587601974",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"11777720285956632126519898515392071627539405001940313098390150593689568177535",
|
||||
"8483603647274280691250972408211651407952870456587066148445913156086740744515",
|
||||
"1"
|
||||
]
|
||||
]
|
||||
}
|
||||
"protocol": "groth16",
|
||||
"curve": "bn128",
|
||||
"nPublic": 6,
|
||||
"vk_alpha_1": [
|
||||
"20124996762962216725442980738609010303800849578410091356605067053491763969391",
|
||||
"9118593021526896828671519912099489027245924097793322973632351264852174143923",
|
||||
"1"
|
||||
],
|
||||
"vk_beta_2": [
|
||||
[
|
||||
"4693952934005375501364248788849686435240706020501681709396105298107971354382",
|
||||
"14346958885444710485362620645446987998958218205939139994511461437152241966681"
|
||||
],
|
||||
[
|
||||
"16851772916911573982706166384196538392731905827088356034885868448550849804972",
|
||||
"823612331030938060799959717749043047845343400798220427319188951998582076532"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0"
|
||||
]
|
||||
],
|
||||
"vk_gamma_2": [
|
||||
[
|
||||
"10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
||||
"11559732032986387107991004021392285783925812861821192530917403151452391805634"
|
||||
],
|
||||
[
|
||||
"8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
||||
"4082367875863433681332203403145435568316851327593401208105741076214120093531"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0"
|
||||
]
|
||||
],
|
||||
"vk_delta_2": [
|
||||
[
|
||||
"8353516066399360694538747105302262515182301251524941126222712285088022964076",
|
||||
"9329524012539638256356482961742014315122377605267454801030953882967973561832"
|
||||
],
|
||||
[
|
||||
"16805391589556134376869247619848130874761233086443465978238468412168162326401",
|
||||
"10111259694977636294287802909665108497237922060047080343914303287629927847739"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0"
|
||||
]
|
||||
],
|
||||
"vk_alphabeta_12": [
|
||||
[
|
||||
[
|
||||
"12608968655665301215455851857466367636344427685631271961542642719683786103711",
|
||||
"9849575605876329747382930567422916152871921500826003490242628251047652318086"
|
||||
],
|
||||
[
|
||||
"6322029441245076030714726551623552073612922718416871603535535085523083939021",
|
||||
"8700115492541474338049149013125102281865518624059015445617546140629435818912"
|
||||
],
|
||||
[
|
||||
"10674973475340072635573101639867487770811074181475255667220644196793546640210",
|
||||
"2926286967251299230490668407790788696102889214647256022788211245826267484824"
|
||||
]
|
||||
],
|
||||
[
|
||||
[
|
||||
"9660441540778523475944706619139394922744328902833875392144658911530830074820",
|
||||
"19548113127774514328631808547691096362144426239827206966690021428110281506546"
|
||||
],
|
||||
[
|
||||
"1870837942477655969123169532603615788122896469891695773961478956740992497097",
|
||||
"12536105729661705698805725105036536744930776470051238187456307227425796690780"
|
||||
],
|
||||
[
|
||||
"21811903352654147452884857281720047789720483752548991551595462057142824037334",
|
||||
"19021616763967199151052893283384285352200445499680068407023236283004353578353"
|
||||
]
|
||||
]
|
||||
],
|
||||
"IC": [
|
||||
[
|
||||
"11992897507809711711025355300535923222599547639134311050809253678876341466909",
|
||||
"17181525095924075896332561978747020491074338784673526378866503154966799128110",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"17018665030246167677911144513385572506766200776123272044534328594850561667818",
|
||||
"18601114175490465275436712413925513066546725461375425769709566180981674884464",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"18799470100699658367834559797874857804183288553462108031963980039244731716542",
|
||||
"13064227487174191981628537974951887429496059857753101852163607049188825592007",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"17432501889058124609368103715904104425610382063762621017593209214189134571156",
|
||||
"13406815149699834788256141097399354592751313348962590382887503595131085938635",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"10320964835612716439094703312987075811498239445882526576970512041988148264481",
|
||||
"9024164961646353611176283204118089412001502110138072989569118393359029324867",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"718355081067365548229685160476620267257521491773976402837645005858953849298",
|
||||
"14635482993933988261008156660773180150752190597753512086153001683711587601974",
|
||||
"1"
|
||||
],
|
||||
[
|
||||
"11777720285956632126519898515392071627539405001940313098390150593689568177535",
|
||||
"8483603647274280691250972408211651407952870456587066148445913156086740744515",
|
||||
"1"
|
||||
]
|
||||
]
|
||||
}
|
89
rln/rln.go
89
rln/rln.go
|
@ -75,14 +75,25 @@ func NewRLNWithFolder(depth int, resourcesFolderPath string) (*RLN, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
// MembershipKeyGen generates a IdentityCredential that can be used for the
|
||||
// registration into the rln membership contract. Returns an error if the key generation fails
|
||||
func (r *RLN) MembershipKeyGen() (*IdentityCredential, error) {
|
||||
generatedKeys := r.w.ExtendedKeyGen()
|
||||
if generatedKeys == nil {
|
||||
return nil, errors.New("error in key generation")
|
||||
func (r *RLN) SetTree(treeHeight uint) error {
|
||||
success := r.w.SetTree(treeHeight)
|
||||
if !success {
|
||||
return errors.New("could not set tree height")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Initialize merkle tree with a list of IDCommitments
|
||||
func (r *RLN) InitTreeWithMembers(idComms []IDCommitment) error {
|
||||
idCommBytes := serializeCommitments(idComms)
|
||||
initSuccess := r.w.InitTreeWithLeaves(idCommBytes)
|
||||
if !initSuccess {
|
||||
return errors.New("could not init tree")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func toIdentityCredential(generatedKeys []byte) (*IdentityCredential, error) {
|
||||
key := &IdentityCredential{
|
||||
IDTrapdoor: [32]byte{},
|
||||
IDNullifier: [32]byte{},
|
||||
|
@ -102,6 +113,27 @@ func (r *RLN) MembershipKeyGen() (*IdentityCredential, error) {
|
|||
return key, nil
|
||||
}
|
||||
|
||||
// MembershipKeyGen generates a IdentityCredential that can be used for the
|
||||
// registration into the rln membership contract. Returns an error if the key generation fails
|
||||
func (r *RLN) MembershipKeyGen() (*IdentityCredential, error) {
|
||||
generatedKeys := r.w.ExtendedKeyGen()
|
||||
if generatedKeys == nil {
|
||||
return nil, errors.New("error in key generation")
|
||||
}
|
||||
return toIdentityCredential(generatedKeys)
|
||||
}
|
||||
|
||||
// SeededMembershipKeyGen generates a deterministic IdentityCredential using a seed
|
||||
// that can be used for the registration into the rln membership contract.
|
||||
// Returns an error if the key generation fails
|
||||
func (r *RLN) SeededMembershipKeyGen(seed []byte) (*IdentityCredential, error) {
|
||||
generatedKeys := r.w.ExtendedSeededKeyGen(seed)
|
||||
if generatedKeys == nil {
|
||||
return nil, errors.New("error in key generation")
|
||||
}
|
||||
return toIdentityCredential(generatedKeys)
|
||||
}
|
||||
|
||||
// appendLength returns length prefixed version of the input with the following format
|
||||
// [len<8>|input<var>], the len is a 8 byte value serialized in little endian
|
||||
|
||||
|
@ -257,7 +289,7 @@ func serializeIndices(indices []MembershipIndex) []byte {
|
|||
// validRoots should contain a sequence of roots in the acceptable windows.
|
||||
// As default, it is set to an empty sequence of roots. This implies that the validity check for the proof's root is skipped
|
||||
func (r *RLN) Verify(data []byte, proof RateLimitProof, roots ...[32]byte) (bool, error) {
|
||||
proofBytes := proof.serialize(data)
|
||||
proofBytes := proof.serializeWithData(data)
|
||||
rootBytes := serialize32(roots)
|
||||
|
||||
res, err := r.w.VerifyWithRoots(proofBytes, rootBytes)
|
||||
|
@ -268,6 +300,19 @@ func (r *RLN) Verify(data []byte, proof RateLimitProof, roots ...[32]byte) (bool
|
|||
return bool(res), nil
|
||||
}
|
||||
|
||||
// RecoverIDSecret returns an IDSecret having obtained before two proofs
|
||||
func (r *RLN) RecoverIDSecret(proof1 RateLimitProof, proof2 RateLimitProof) (IDSecretHash, error) {
|
||||
proof1Bytes := proof1.serialize()
|
||||
proof2Bytes := proof2.serialize()
|
||||
secret, err := r.w.RecoverIDSecret(proof1Bytes, proof2Bytes)
|
||||
if err != nil {
|
||||
return IDSecretHash{}, err
|
||||
}
|
||||
var result IDSecretHash
|
||||
copy(result[:], secret)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// InsertMember adds the member to the tree
|
||||
func (r *RLN) InsertMember(idComm IDCommitment) error {
|
||||
insertionSuccess := r.w.SetNextLeaf(idComm[:])
|
||||
|
@ -289,6 +334,15 @@ func (r *RLN) InsertMembers(index MembershipIndex, idComms []IDCommitment) error
|
|||
return nil
|
||||
}
|
||||
|
||||
// Insert a member in the tree at specified index
|
||||
func (r *RLN) InsertMemberAt(index MembershipIndex, idComm IDCommitment) error {
|
||||
insertionSuccess := r.w.SetLeaf(index, idComm[:])
|
||||
if !insertionSuccess {
|
||||
return errors.New("could not insert member")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteMember removes an IDCommitment key from the tree. The index
|
||||
// parameter is the position of the id commitment key to be deleted from the tree.
|
||||
// The deleted id commitment key is replaced with a zero leaf
|
||||
|
@ -362,11 +416,8 @@ func CalcMerkleRoot(list []IDCommitment) (MerkleNode, error) {
|
|||
return MerkleNode{}, err
|
||||
}
|
||||
|
||||
// create a Merkle tree
|
||||
for _, c := range list {
|
||||
if err := rln.InsertMember(c); err != nil {
|
||||
return MerkleNode{}, err
|
||||
}
|
||||
if err := rln.InsertMembers(0, list); err != nil {
|
||||
return MerkleNode{}, err
|
||||
}
|
||||
|
||||
return rln.GetMerkleRoot()
|
||||
|
@ -405,3 +456,17 @@ func CreateMembershipList(n int) ([]IdentityCredential, MerkleNode, error) {
|
|||
|
||||
return output, root, nil
|
||||
}
|
||||
|
||||
// SetMetadata stores serialized data
|
||||
func (r *RLN) SetMetadata(metadata []byte) error {
|
||||
success := r.w.SetMetadata(metadata)
|
||||
if !success {
|
||||
return errors.New("could not set metadata")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetMetadata returns the stored serialized metadata
|
||||
func (r *RLN) GetMetadata() ([]byte, error) {
|
||||
return r.w.GetMetadata()
|
||||
}
|
||||
|
|
|
@ -24,15 +24,21 @@ func serialize(idKey IDSecretHash, memIndex MembershipIndex, epoch Epoch, msg []
|
|||
// this conversion is used in the proof verification proc
|
||||
// the order of serialization is based on https://github.com/kilic/rln/blob/7ac74183f8b69b399e3bc96c1ae8ab61c026dc43/src/public.rs#L205
|
||||
// [ proof<128> | root<32> | epoch<32> | share_x<32> | share_y<32> | nullifier<32> | rln_identifier<32> | signal_len<8> | signal<var> ]
|
||||
func (r RateLimitProof) serialize(data []byte) []byte {
|
||||
func (r RateLimitProof) serializeWithData(data []byte) []byte {
|
||||
lenPrefMsg := appendLength(data)
|
||||
proofBytes := r.serialize()
|
||||
proofBytes = append(proofBytes, lenPrefMsg...)
|
||||
return proofBytes
|
||||
}
|
||||
|
||||
// serialize converts a RateLimitProof to a byte seq
|
||||
// [ proof<128> | root<32> | epoch<32> | share_x<32> | share_y<32> | nullifier<32> | rln_identifier<32>
|
||||
func (r RateLimitProof) serialize() []byte {
|
||||
proofBytes := append(r.Proof[:], r.MerkleRoot[:]...)
|
||||
proofBytes = append(proofBytes, r.Epoch[:]...)
|
||||
proofBytes = append(proofBytes, r.ShareX[:]...)
|
||||
proofBytes = append(proofBytes, r.ShareY[:]...)
|
||||
proofBytes = append(proofBytes, r.Nullifier[:]...)
|
||||
proofBytes = append(proofBytes, r.RLNIdentifier[:]...)
|
||||
proofBytes = append(proofBytes, lenPrefMsg...)
|
||||
|
||||
return proofBytes
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ func init() {
|
|||
// STATIC_GROUP_MERKLE_ROOT is the root of the Merkle tree constructed from the STATIC_GROUP_KEYS above
|
||||
// only identity commitments are used for the Merkle tree construction
|
||||
// the root is created locally, using createMembershipList proc from waku_rln_relay_utils module, and the result is hardcoded in here
|
||||
const STATIC_GROUP_MERKLE_ROOT = "25caa6e82a7476394b0ad5bfbca174a0a842479e70eaaeee14fa8096e49072ca"
|
||||
const STATIC_GROUP_MERKLE_ROOT = "ca7290e49680fa14eeaeea709e4742a8a074a1bcbfd50a4b3976742ae8a6ca25"
|
||||
|
||||
const EPOCH_UNIT_SECONDS = uint64(10) // the rln-relay epoch length in seconds
|
||||
|
||||
|
|
Loading…
Reference in New Issue