Documentation ¶
Index ¶
- Constants
- func BytesToBigInt(b []byte) *big.Int
- func DoubleSha256(data []byte) []byte
- func EcdsaSign(prv *PrvKey, hash []byte) ([]byte, error)
- func EcdsaVerify(pub *PubKey, hash []byte, sign []byte) error
- func Hash160(data []byte) []byte
- func Ripemd160(data []byte) []byte
- func Ripemd160Size() int
- func SchnorrSign(prv *PrvKey, hash []byte) ([]byte, error)
- func SchnorrVerify(pub *PubKey, hash []byte, sign []byte) error
- func Sha256(data []byte) []byte
- type EcdsaAlice
- func (alice *EcdsaAlice) ScriptlessPhase1(pub2 *PubKey) *PubKey
- func (alice *EcdsaAlice) ScriptlessPhase2(hash []byte) (*big.Int, *paillier.PubKey, *secp256k1.Scalar)
- func (alice *EcdsaAlice) ScriptlessPhase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
- func (alice *EcdsaAlice) ScriptlessPhase4(encpk2 *big.Int, encpub2 *paillier.PubKey, shareR *secp256k1.Scalar) (*big.Int, error)
- func (alice *EcdsaAlice) ScriptlessPhase5(shareR *secp256k1.Scalar, sign2 *big.Int) (*big.Int, error)
- func (alice *EcdsaAlice) ScriptlessPhase6(alicesig *big.Int, bobsig *big.Int) *big.Int
- type EcdsaBob
- func (bob *EcdsaBob) ScriptlessPhase1(pub2 *PubKey) *PubKey
- func (bob *EcdsaBob) ScriptlessPhase2(hash []byte) (*big.Int, *paillier.PubKey, *secp256k1.Scalar)
- func (bob *EcdsaBob) ScriptlessPhase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
- func (bob *EcdsaBob) ScriptlessPhase4(encpk2 *big.Int, encpub2 *paillier.PubKey, shareR *secp256k1.Scalar) (*big.Int, error)
- func (bob *EcdsaBob) ScriptlessPhase5(shareR *secp256k1.Scalar, sign2 *big.Int) (*big.Int, error)
- func (bob *EcdsaBob) ScriptlessPhase6(shareR *secp256k1.Scalar, sig *big.Int) ([]byte, error)
- type EcdsaParty
- func (party *EcdsaParty) Close()
- func (party *EcdsaParty) Phase1(pub2 *PubKey) *PubKey
- func (party *EcdsaParty) Phase2(hash []byte) (*big.Int, *paillier.PubKey, *secp256k1.Scalar)
- func (party *EcdsaParty) Phase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
- func (party *EcdsaParty) Phase4(encpk2 *big.Int, encpub2 *paillier.PubKey, shareR *secp256k1.Scalar) (*big.Int, error)
- func (party *EcdsaParty) Phase5(shareR *secp256k1.Scalar, sign2 *big.Int) ([]byte, error)
- type Merkle
- type Node
- type PrvKey
- type PubKey
- func (p *PubKey) Add(p2 *PubKey) *PubKey
- func (p *PubKey) Hash160() []byte
- func (p *PubKey) Serialize() []byte
- func (p *PubKey) SerializeCompressed() []byte
- func (p *PubKey) SerializeHybrid() []byte
- func (p *PubKey) SerializeUncompressed() []byte
- func (p *PubKey) XBytes() []byte
- func (p *PubKey) YBytes() []byte
- type SchnorrParty
- func (party *SchnorrParty) Close()
- func (party *SchnorrParty) Phase1(pub2 *PubKey) *PubKey
- func (party *SchnorrParty) Phase2(hash []byte) *secp256k1.Scalar
- func (party *SchnorrParty) Phase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
- func (party *SchnorrParty) Phase4(sharePub *PubKey, shareR *secp256k1.Scalar) ([]byte, error)
- func (party *SchnorrParty) Phase5(shareR *secp256k1.Scalar, sigs ...[]byte) ([]byte, error)
- type SignatureEcdsa
- type SignatureSchnorr
Constants ¶
const (
// PrvKeyBytesLen -- defines the length in bytes of a serialized private key.
PrvKeyBytesLen = 32
)
Variables ¶
This section is empty.
Functions ¶
func BytesToBigInt ¶
BytesToBigInt -- returns big int for the b bytes represents.
func DoubleSha256 ¶
DoubleSha256 -- returns sha256(sha256) bytes.
func EcdsaVerify ¶
EcdsaVerify -- used to verify the ecdsa signature.
func SchnorrSign ¶
SchnorrSign -- used get the schnorr signature.
func SchnorrVerify ¶
SchnorrVerify -- used to verify the schnorr signature.
Types ¶
type EcdsaAlice ¶
type EcdsaAlice struct {
*EcdsaParty
}
EcdsaAlice --
func NewEcdsaAlice ¶
func NewEcdsaAlice(prv *PrvKey) *EcdsaAlice
NewEcdsaAlice -- creates new EcdsaAlice.
func (*EcdsaAlice) ScriptlessPhase1 ¶
func (alice *EcdsaAlice) ScriptlessPhase1(pub2 *PubKey) *PubKey
ScriptlessPhase1 -- used to generate final pubkey of parties.
func (*EcdsaAlice) ScriptlessPhase2 ¶
func (alice *EcdsaAlice) ScriptlessPhase2(hash []byte) (*big.Int, *paillier.PubKey, *secp256k1.Scalar)
ScriptlessPhase2 -- used to generate k, kinv, scalarR.
func (*EcdsaAlice) ScriptlessPhase3 ¶
func (alice *EcdsaAlice) ScriptlessPhase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
ScriptlessPhase3 -- return the shared R.
func (*EcdsaAlice) ScriptlessPhase4 ¶
func (alice *EcdsaAlice) ScriptlessPhase4(encpk2 *big.Int, encpub2 *paillier.PubKey, shareR *secp256k1.Scalar) (*big.Int, error)
ScriptlessPhase4 -- return the homomorphic ciphertext.
func (*EcdsaAlice) ScriptlessPhase5 ¶
func (alice *EcdsaAlice) ScriptlessPhase5(shareR *secp256k1.Scalar, sign2 *big.Int) (*big.Int, error)
ScriptlessPhase5 -- return the partial signature of alice party.
func (*EcdsaAlice) ScriptlessPhase6 ¶
ScriptlessPhase6 -- get the secret T.
type EcdsaBob ¶
type EcdsaBob struct { *EcdsaParty // contains filtered or unexported fields }
EcdsaBob --
func NewEcdsaBob ¶
NewEcdsaBob -- creates new EcdsaBob with a secret.
func (*EcdsaBob) ScriptlessPhase1 ¶
ScriptlessPhase1 -- used to generate final pubkey of parties.
func (*EcdsaBob) ScriptlessPhase2 ¶
ScriptlessPhase2 -- used to generate k, kinv, scalarR. R=bobR*secret
func (*EcdsaBob) ScriptlessPhase3 ¶
ScriptlessPhase3 -- return the shared R.
func (*EcdsaBob) ScriptlessPhase4 ¶
func (bob *EcdsaBob) ScriptlessPhase4(encpk2 *big.Int, encpub2 *paillier.PubKey, shareR *secp256k1.Scalar) (*big.Int, error)
ScriptlessPhase4 -- return the homomorphic ciphertext.
func (*EcdsaBob) ScriptlessPhase5 ¶
ScriptlessPhase5 -- return the final signature of two party.
type EcdsaParty ¶
EcdsaParty -- ECDSA party struct.
func NewEcdsaParty ¶
func NewEcdsaParty(prv *PrvKey) *EcdsaParty
NewEcdsaParty -- creates new EcdsaParty.
func (*EcdsaParty) Phase1 ¶
func (party *EcdsaParty) Phase1(pub2 *PubKey) *PubKey
Phase1 -- used to generate final pubkey of parties. Return the shared PubKey.
func (*EcdsaParty) Phase3 ¶
func (party *EcdsaParty) Phase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
Phase3 -- set party2's r2 to this party. Return the shared R.
type Merkle ¶
type Merkle struct {
// contains filtered or unexported fields
}
Merkle --
func NewMerkle ¶
NewMerkle -- create new Merkle. children nodes. A diagram depicting how this works for bitcoin transactions where h(x) is a double sha256 follows:
root = h1234 = h(h12 + h34) / \ h12 = h(h1 + h2) h34 = h(h3 + h4) / \ / \ h1 = h(tx1) h2 = h(tx2) h3 = h(tx3) h4 = h(tx4)
If the right is nil(the size is not power of 2), hashed with itself.
type PrvKey ¶
type PrvKey ecdsa.PrivateKey
PrvKey --
func PrvKeyFromBytes ¶
PrvKeyFromBytes -- returns a private and public key for secp256k1 curve.
type PubKey ¶
PubKey -- an ecdsa.PubKey with additional functions to serialize in uncompressed, compressed, and hybrid formats.
func PubKeyFromBytes ¶
PubKeyFromBytes -- parse bytes to public key.
func (*PubKey) SerializeCompressed ¶
SerializeCompressed -- encoding a public key in a 33-byte compressed foramt.
func (*PubKey) SerializeHybrid ¶
SerializeHybrid -- encoding a public key in a 65-byte hybrid format.
func (*PubKey) SerializeUncompressed ¶
SerializeUncompressed -- encoding public key in a 65-byte uncompressed format.
type SchnorrParty ¶
SchnorrParty -- Schnorr party struct.
func NewSchnorrParty ¶
func NewSchnorrParty(prv *PrvKey) (*SchnorrParty, error)
NewSchnorrParty -- creates new SchnorrParty.
func (*SchnorrParty) Phase1 ¶
func (party *SchnorrParty) Phase1(pub2 *PubKey) *PubKey
Phase1 -- used to generate final pubkey of parties. Return the shared PubKey.
func (*SchnorrParty) Phase2 ¶
func (party *SchnorrParty) Phase2(hash []byte) *secp256k1.Scalar
Phase2 -- used to generate k, kinv, scalarR. Return the party scalar R.
func (*SchnorrParty) Phase3 ¶
func (party *SchnorrParty) Phase3(r2 *secp256k1.Scalar) *secp256k1.Scalar
Phase3 -- return shared scalar R.
type SignatureEcdsa ¶
SignatureEcdsa -- a type representing an ECDSA signature.
func NewSignatureEcdsa ¶
func NewSignatureEcdsa() *SignatureEcdsa
NewSignatureEcdsa -- create new SignatureEcdsa.
func (*SignatureEcdsa) Deserialize ¶
func (sig *SignatureEcdsa) Deserialize(sign []byte) error
Deserialize -- used to deserialize the signature to struct.
func (*SignatureEcdsa) Serialize ¶
func (sig *SignatureEcdsa) Serialize() ([]byte, error)
Serialize -- used to serialize the struct to signature.
type SignatureSchnorr ¶
SignatureSchnorr -- a type representing an schnorr signature.
func NewSignatureSchnorr ¶
func NewSignatureSchnorr() *SignatureSchnorr
NewSignatureSchnorr -- create new SignatureSchnorr.
func (*SignatureSchnorr) Deserialize ¶
func (sig *SignatureSchnorr) Deserialize(sign []byte) error
Deserialize -- used to deserialize the signature to struct.
func (*SignatureSchnorr) Serialize ¶
func (sig *SignatureSchnorr) Serialize() ([]byte, error)
Serialize -- used to serialize the struct to signature.