mirror of
https://github.com/onsonr/sonr.git
synced 2025-03-10 21:09:11 +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**
83 lines
2.7 KiB
Go
Executable File
83 lines
2.7 KiB
Go
Executable File
package native
|
|
|
|
// SswuParams for computing the Simplified SWU mapping
|
|
// for hash to curve implementations
|
|
type SswuParams struct {
|
|
C1, C2, A, B, Z [FieldLimbs]uint64
|
|
}
|
|
|
|
// Osswu3mod4 computes the simplified map optmized for 3 mod 4 primes
|
|
// https://tools.ietf.org/html/draft-irtf-cfrg-hash-to-curve-11#appendix-G.2.1
|
|
func (p *SswuParams) Osswu3mod4(u *Field) (x, y *Field) {
|
|
var tv1, tv2, tv3, tv4, xd, x1n, x2n, gxd, gx1, aNeg, zA, y1, y2 [FieldLimbs]uint64
|
|
var wasInverted int
|
|
u.Arithmetic.Mul(&tv1, &u.Value, &u.Value) // tv1 = u^2
|
|
u.Arithmetic.Mul(&tv3, &p.Z, &tv1) // tv3 = z * tv1
|
|
u.Arithmetic.Square(&tv2, &tv3) // tv2 = tv3^2
|
|
u.Arithmetic.Add(&xd, &tv2, &tv3) // xd = tv2 + tv3
|
|
u.Arithmetic.Add(&x1n, &u.Params.R, &xd) // x1n = (xd + 1)
|
|
u.Arithmetic.Mul(&x1n, &x1n, &p.B) // x1n * B
|
|
u.Arithmetic.Neg(&aNeg, &p.A)
|
|
u.Arithmetic.Mul(&xd, &xd, &aNeg) // xd = -A * xd
|
|
|
|
xdIsZero := (&Field{
|
|
Value: xd,
|
|
}).IsZero()
|
|
u.Arithmetic.Mul(&zA, &p.Z, &p.A)
|
|
u.Arithmetic.Selectznz(&xd, &xd, &zA, xdIsZero) // xd = z * A if xd == 0
|
|
|
|
u.Arithmetic.Square(&tv2, &xd) // tv2 = xd^2
|
|
u.Arithmetic.Mul(&gxd, &tv2, &xd) // gxd = tv2 * xd
|
|
u.Arithmetic.Mul(&tv2, &tv2, &p.A) // tv2 = A * tv2
|
|
|
|
u.Arithmetic.Square(&gx1, &x1n) // gx1 = x1n^2
|
|
u.Arithmetic.Add(&gx1, &gx1, &tv2) // gx1 = gx1 + tv2
|
|
u.Arithmetic.Mul(&gx1, &gx1, &x1n) // gx1 = gx1 * x1n
|
|
u.Arithmetic.Mul(&tv2, &gxd, &p.B) // tv2 = B * gxd
|
|
u.Arithmetic.Add(&gx1, &gx1, &tv2) // gx1 = gx1 + tv2
|
|
|
|
u.Arithmetic.Square(&tv4, &gxd) // tv4 = gxd^2
|
|
u.Arithmetic.Mul(&tv2, &gx1, &gxd) // tv2 = gx1 * gxd
|
|
u.Arithmetic.Mul(&tv4, &tv4, &tv2) // tv4 = tv4 * tv2
|
|
|
|
Pow(&y1, &tv4, &p.C1, u.Params, u.Arithmetic) // y1 = tv4^C1
|
|
u.Arithmetic.Mul(&y1, &y1, &tv2) //y1 = y1 * tv2
|
|
u.Arithmetic.Mul(&x2n, &tv3, &x1n) // x2n = tv3 * x1n
|
|
|
|
u.Arithmetic.Mul(&y2, &y1, &p.C2) // y2 = y1 * c2
|
|
u.Arithmetic.Mul(&y2, &y2, &tv1) // y2 = y2 * tv1
|
|
u.Arithmetic.Mul(&y2, &y2, &u.Value) // y2 = y2 * u
|
|
|
|
u.Arithmetic.Square(&tv2, &y1) // tv2 = y1^2
|
|
u.Arithmetic.Mul(&tv2, &tv2, &gxd) // tv2 = tv2 * gxd
|
|
|
|
e2 := (&Field{Value: tv2}).Equal(&Field{Value: gx1})
|
|
|
|
x = new(Field).Set(u)
|
|
y = new(Field).Set(u)
|
|
|
|
// If e2, x = x1, else x = x2
|
|
u.Arithmetic.Selectznz(&x.Value, &x2n, &x1n, e2)
|
|
|
|
// xn / xd
|
|
u.Arithmetic.Invert(&wasInverted, &tv1, &xd)
|
|
u.Arithmetic.Mul(&tv1, &x.Value, &tv1)
|
|
u.Arithmetic.Selectznz(&x.Value, &x.Value, &tv1, wasInverted)
|
|
|
|
// If e2, y = y1, else y = y2
|
|
u.Arithmetic.Selectznz(&y.Value, &y2, &y1, e2)
|
|
|
|
uBytes := u.Bytes()
|
|
yBytes := y.Bytes()
|
|
|
|
usign := uBytes[0] & 1
|
|
ysign := yBytes[0] & 1
|
|
|
|
// Fix sign of y
|
|
if usign != ysign {
|
|
y.Neg(y)
|
|
}
|
|
|
|
return
|
|
}
|