mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-11 13:29:12 +00:00
- **refactor: remove unused auth components** - **refactor: improve devbox configuration and deployment process** - **refactor: improve devnet and testnet setup** - **fix: update templ version to v0.2.778** - **refactor: rename pkl/net.matrix to pkl/matrix.net** - **refactor: migrate webapp components to nebula** - **refactor: protobuf types** - **chore: update dependencies for improved security and stability** - **feat: implement landing page and vault gateway servers** - **refactor: Migrate data models to new module structure and update related files** - **feature/1121-implement-ucan-validation** - **refactor: Replace hardcoded constants with model types in attns.go** - **feature/1121-implement-ucan-validation** - **chore: add origin Host struct and update main function to handle multiple hosts** - **build: remove unused static files from dwn module** - **build: remove unused static files from dwn module** - **refactor: Move DWN models to common package** - **refactor: move models to pkg/common** - **refactor: move vault web app assets to embed module** - **refactor: update session middleware import path** - **chore: configure port labels and auto-forwarding behavior** - **feat: enhance devcontainer configuration** - **feat: Add UCAN middleware for Echo with flexible token validation** - **feat: add JWT middleware for UCAN authentication** - **refactor: update package URI and versioning in PklProject files** - **fix: correct sonr.pkl import path** - **refactor: move JWT related code to auth package** - **feat: introduce vault configuration retrieval and management** - **refactor: Move vault components to gateway module and update file paths** - **refactor: remove Dexie and SQLite database implementations** - **feat: enhance frontend with PWA features and WASM integration** - **feat: add Devbox features and streamline Dockerfile** - **chore: update dependencies to include TigerBeetle** - **chore(deps): update go version to 1.23** - **feat: enhance devnet setup with PATH environment variable and updated PWA manifest** - **fix: upgrade tigerbeetle-go dependency and remove indirect dependency** - **feat: add PostgreSQL support to devnet and testnet deployments** - **refactor: rename keyshare cookie to token cookie** - **feat: upgrade Go version to 1.23.3 and update dependencies** - **refactor: update devnet and testnet configurations** - **feat: add IPFS configuration for devnet** - **I'll help you update the ipfs.config.pkl to include all the peers from the shell script. Here's the updated configuration:** - **refactor: move mpc package to crypto directory** - **feat: add BIP32 support for various cryptocurrencies** - **feat: enhance ATN.pkl with additional capabilities** - **refactor: simplify smart account and vault attenuation creation** - **feat: add new capabilities to the Attenuation type** - **refactor: Rename MPC files for clarity and consistency** - **feat: add DIDKey support for cryptographic operations** - **feat: add devnet and testnet deployment configurations** - **fix: correct key derivation in bip32 package** - **refactor: rename crypto/bip32 package to crypto/accaddr** - **fix: remove duplicate indirect dependency** - **refactor: move vault package to root directory** - **refactor: update routes for gateway and vault** - **refactor: remove obsolete web configuration file** - **refactor: remove unused TigerBeetle imports and update host configuration** - **refactor: adjust styles directory path** - **feat: add broadcastTx and simulateTx functions to gateway** - **feat: add PinVault handler**
123 lines
4.0 KiB
Go
Executable File
123 lines
4.0 KiB
Go
Executable File
//
|
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
|
|
package mina
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/onsonr/sonr/crypto/core/curves/native/pasta/fp"
|
|
"github.com/onsonr/sonr/crypto/core/curves/native/pasta/fq"
|
|
)
|
|
|
|
func TestPoseidonHash(t *testing.T) {
|
|
// Reference https://github.com/o1-labs/proof-systems/blob/master/oracle/tests/test_vectors/3w.json
|
|
testVectors := []struct {
|
|
input []*fp.Fp
|
|
output *fq.Fq
|
|
}{
|
|
{
|
|
input: []*fp.Fp{},
|
|
output: hexToFq("1b3251b6912d82edc78bbb0a5c88f0c6fde1781bc3e654123fa6862a4c63e617"),
|
|
},
|
|
{
|
|
input: []*fp.Fp{
|
|
hexToFp("df698e389c6f1987ffe186d806f8163738f5bf22e8be02572cce99dc6a4ab030"),
|
|
},
|
|
output: hexToFq("f9b1b6c5f8c98017c6b35ac74bc689b6533d6dbbee1fd868831b637a43ea720c"),
|
|
},
|
|
{
|
|
input: []*fp.Fp{
|
|
hexToFp("56b648a5a85619814900a6b40375676803fe16fb1ad2d1fb79115eb1b52ac026"),
|
|
hexToFp("f26a8a03d9c9bbd9c6b2a1324d2a3f4d894bafe25a7e4ad1a498705f4026ff2f"),
|
|
},
|
|
output: hexToFq("7a556e93bcfbd27b55867f533cd1df293a7def60dd929a086fdd4e70393b0918"),
|
|
},
|
|
{
|
|
input: []*fp.Fp{
|
|
hexToFp("075c41fa23e4690694df5ded43624fd60ab7ee6ec6dd48f44dc71bc206cecb26"),
|
|
hexToFp("a4e2beebb09bd02ad42bbccc11051e8262b6ef50445d8382b253e91ab1557a0d"),
|
|
hexToFp("7dfc23a1242d9c0d6eb16e924cfba342bb2fccf36b8cbaf296851f2e6c469639"),
|
|
},
|
|
output: hexToFq("f94b39a919aab06f43f4a4b5a3e965b719a4dbd2b9cd26d2bba4197b10286b35"),
|
|
},
|
|
{
|
|
input: []*fp.Fp{
|
|
hexToFp("a1a659b14e80d47318c6fcdbbd388de4272d5c2815eb458cf4f196d52403b639"),
|
|
hexToFp("5e33065d1801131b64d13038ff9693a7ef6283f24ec8c19438d112ff59d50f04"),
|
|
hexToFp("38a8f4d0a9b6d0facdc4e825f6a2ba2b85401d5de119bf9f2bcb908235683e06"),
|
|
hexToFp("3456d0313a30d7ccb23bd71ed6aa70ab234dad683d8187b677aef73f42f4f52e"),
|
|
},
|
|
output: hexToFq("cc1ccfa964fd6ef9ff1994beb53cfce9ebe1212847ce30e4c64f0777875aec34"),
|
|
},
|
|
{
|
|
input: []*fp.Fp{
|
|
hexToFp("bccfee48dc76bb991c97bd531cf489f4ee37a66a15f5cfac31bdd4f159d4a905"),
|
|
hexToFp("2d106fb21a262f85fd400a995c6d74bad48d8adab2554046871c215e585b072b"),
|
|
hexToFp("8300e93ee8587956534d0756bb2aa575e5878c670cff5c8e3e55c62632333c06"),
|
|
hexToFp("879c32da31566f6d16afdefff94cba5260fec1057e97f19fc9a61dc2c54a6417"),
|
|
hexToFp("9c0aa6e5501cfb2d08aeaea5b3cddac2c9bee85d13324118b44bafb63a59611e"),
|
|
},
|
|
output: hexToFq("cf7b9c2128f0e2c0fed4e1eca8d5954b629640c2458d24ba238c1bd3ccbc8e12"),
|
|
},
|
|
}
|
|
for _, tv := range testVectors {
|
|
ctx := new(Context).Init(ThreeW, NetworkType(NullNet))
|
|
ctx.Update(tv.input)
|
|
res := ctx.Digest()
|
|
require.True(t, res.Equal(tv.output))
|
|
}
|
|
testVectors = []struct {
|
|
input []*fp.Fp
|
|
output *fq.Fq
|
|
}{
|
|
{
|
|
input: []*fp.Fp{
|
|
hexToFp("0f48c65bd25f85f3e4ea4efebeb75b797bd743603be04b4ead845698b76bd331"),
|
|
hexToFp("0f48c65bd25f85f3e4ea4efebeb75b797bd743603be04b4ead845698b76bd331"),
|
|
hexToFp("f34b505e1a05ecfb327d8d664ff6272ddf5cc1f69618bb6a4407e9533067e703"),
|
|
hexToFp("0f48c65bd25f85f3e4ea4efebeb75b797bd743603be04b4ead845698b76bd331"),
|
|
hexToFp("ac7cb9c568955737eca56f855954f394cc6b05ac9b698ba3d974f029177cb427"),
|
|
hexToFp("010141eca06991fe68dcbd799d93037522dc6c4dead1d77202e8c2ea8f5b1005"),
|
|
hexToFp("0300000000000000010000000000000090010000204e0000021ce8d0d2e64012"),
|
|
hexToFp("9b030903692b6b7b030000000000000000000000000000000000800100000000"),
|
|
hexToFp("000000a800000000000000000000000000000000000000000000000000000000"),
|
|
},
|
|
output: &fq.Fq{
|
|
1348483115953159504,
|
|
14115862092770957043,
|
|
15858311826851986539,
|
|
1644043871107534594,
|
|
},
|
|
},
|
|
}
|
|
for _, tv := range testVectors {
|
|
ctx := new(Context).Init(ThreeW, NetworkType(MainNet))
|
|
ctx.Update(tv.input)
|
|
res := ctx.Digest()
|
|
require.True(t, res.Equal(tv.output))
|
|
}
|
|
}
|
|
|
|
func hexToFp(s string) *fp.Fp {
|
|
var buffer [32]byte
|
|
input, _ := hex.DecodeString(s)
|
|
copy(buffer[:], input)
|
|
f, _ := new(fp.Fp).SetBytes(&buffer)
|
|
return f
|
|
}
|
|
|
|
func hexToFq(s string) *fq.Fq {
|
|
var buffer [32]byte
|
|
input, _ := hex.DecodeString(s)
|
|
copy(buffer[:], input)
|
|
f, _ := new(fq.Fq).SetBytes(&buffer)
|
|
return f
|
|
}
|