mirror of
https://github.com/QuilibriumNetwork/ceremonyclient.git
synced 2026-03-11 11:18:13 +08:00
* roll up v2.0.1-b2 to develop * b2-fixed * adjust return data of fast sync so it doesn't return the earliest frame * -b3 * fix: announce peer based on leading frame, not initial frame; fix: looping bug * fix: last batch fails due to underflow; qol: make logging chattier * -b4 * resolve frame cache issue * fix: mint loop + re-migrate * fix: register execution panic * fix: mint loop, other side * fix: handle unexpected return of nil status * final -b4 * handle subtle change to migration * qol: add heuristic to handle corruption scenario * bump genesis * qol: use separate channel for worker * final parameterization, parallelize streams * deprecate signers 10, 11, 14, 17 * adjust signatory check size to match rotated out signers
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package token
|
|
|
|
import (
|
|
"encoding/binary"
|
|
|
|
"github.com/iden3/go-iden3-crypto/poseidon"
|
|
"source.quilibrium.com/quilibrium/monorepo/node/execution/intrinsics/token/application"
|
|
"source.quilibrium.com/quilibrium/monorepo/node/protobufs"
|
|
)
|
|
|
|
func GetAddressOfCoin(
|
|
coin *protobufs.Coin,
|
|
frameNumber uint64,
|
|
seqno uint64,
|
|
) ([]byte, error) {
|
|
eval := []byte{}
|
|
eval = append(eval, application.TOKEN_ADDRESS...)
|
|
eval = binary.BigEndian.AppendUint64(eval, frameNumber)
|
|
if frameNumber != 0 {
|
|
eval = binary.BigEndian.AppendUint64(eval, seqno)
|
|
}
|
|
eval = append(eval, coin.Amount...)
|
|
eval = append(eval, coin.Intersection...)
|
|
eval = binary.BigEndian.AppendUint32(eval, 0)
|
|
eval = append(eval, coin.Owner.GetImplicitAccount().Address...)
|
|
addressBI, err := poseidon.HashBytes(eval)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return addressBI.FillBytes(make([]byte, 32)), nil
|
|
}
|
|
|
|
func GetAddressOfPreCoinProof(
|
|
proof *protobufs.PreCoinProof,
|
|
) ([]byte, error) {
|
|
eval := []byte{}
|
|
eval = append(eval, application.TOKEN_ADDRESS...)
|
|
eval = append(eval, proof.Amount...)
|
|
eval = binary.BigEndian.AppendUint32(eval, proof.Index)
|
|
eval = append(eval, proof.IndexProof...)
|
|
eval = append(eval, proof.Commitment...)
|
|
eval = append(eval, proof.Proof...)
|
|
eval = binary.BigEndian.AppendUint32(eval, proof.Parallelism)
|
|
eval = binary.BigEndian.AppendUint32(eval, proof.Difficulty)
|
|
eval = binary.BigEndian.AppendUint32(eval, 0)
|
|
eval = append(eval, proof.Owner.GetImplicitAccount().Address...)
|
|
addressBI, err := poseidon.HashBytes(eval)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return addressBI.FillBytes(make([]byte, 32)), nil
|
|
}
|