child

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAXUINT32       = 2147483647
	SHA512BlOCKSIZE = 1024
	MAXUINT64       = 18446744073709551615

	SHA512PADDING = 896
)

We implement a version of "garbled circuit" according to paper: "Better Concrete Security for Half-Gates Garbling" and "Two Halves Make a Whole Reducing data Transfer in Garbled Circuits using Half Gates". We support the parse of Bristol fashion ref: https://homes.esat.kuleuven.be/~nsmart/MPC/

View Source
const (
	// MinHardenKey is the first index of "harded" child key in the bip32 spec
	MinHardenKey = uint32(0x80000000)

	// PublicKeyCompressedLength is the byte count of a compressed public key
	PublicKeyCompressedLength = 33
)
View Source
const (
	PaillierLength = 2048
)

Variables

View Source
var (
	ErrPeerNotFound = errors.New("peer message not found")
	ErrInvalidSeed  = errors.New("invalid seed")
)
View Source
var (
	// ErrSliceLength is returned if two slices are different.
	ErrSliceLength = errors.New("two slices are different")
	// ErrVerifyFailure is returned the verify failures.
	ErrVerifyFailure = errors.New("the verify failures")
)
View Source
var (
	ConstantSHA512 = []uint64{
		0x428a2f98d728ae22,
		0x7137449123ef65cd,
		0xb5c0fbcfec4d3b2f,
		0xe9b5dba58189dbbc,
		0x3956c25bf348b538,
		0x59f111f1b605d019,
		0x923f82a4af194f9b,
		0xab1c5ed5da6d8118,
		0xd807aa98a3030242,
		0x12835b0145706fbe,
		0x243185be4ee4b28c,
		0x550c7dc3d5ffb4e2,
		0x72be5d74f27b896f,
		0x80deb1fe3b1696b1,
		0x9bdc06a725c71235,
		0xc19bf174cf692694,
		0xe49b69c19ef14ad2,
		0xefbe4786384f25e3,
		0x0fc19dc68b8cd5b5,
		0x240ca1cc77ac9c65,
		0x2de92c6f592b0275,
		0x4a7484aa6ea6e483,
		0x5cb0a9dcbd41fbd4,
		0x76f988da831153b5,
		0x983e5152ee66dfab,
		0xa831c66d2db43210,
		0xb00327c898fb213f,
		0xbf597fc7beef0ee4,
		0xc6e00bf33da88fc2,
		0xd5a79147930aa725,
		0x06ca6351e003826f,
		0x142929670a0e6e70,
		0x27b70a8546d22ffc,
		0x2e1b21385c26c926,
		0x4d2c6dfc5ac42aed,
		0x53380d139d95b3df,
		0x650a73548baf63de,
		0x766a0abb3c77b2a8,
		0x81c2c92e47edaee6,
		0x92722c851482353b,
		0xa2bfe8a14cf10364,
		0xa81a664bbc423001,
		0xc24b8b70d0f89791,
		0xc76c51a30654be30,
		0xd192e819d6ef5218,
		0xd69906245565a910,
		0xf40e35855771202a,
		0x106aa07032bbd1b8,
		0x19a4c116b8d2d0c8,
		0x1e376c085141ab53,
		0x2748774cdf8eeb99,
		0x34b0bcb5e19b48a8,
		0x391c0cb3c5c95a63,
		0x4ed8aa4ae3418acb,
		0x5b9cca4f7763e373,
		0x682e6ff3d6b2b8a3,
		0x748f82ee5defb2fc,
		0x78a5636f43172f60,
		0x84c87814a1f0ab72,
		0x8cc702081a6439ec,
		0x90befffa23631e28,
		0xa4506cebde82bde9,
		0xbef9a3f7b2c67915,
		0xc67178f2e372532b,
		0xca273eceea26619c,
		0xd186b8c721c0c207,
		0xeada7dd6cde0eb1e,
		0xf57d4f7fee6ed178,
		0x06f067aa72176fba,
		0x0a637dc5a2c898a6,
		0x113f9804bef90dae,
		0x1b710b35131c471b,
		0x28db77f523047d84,
		0x32caab7b40c72493,
		0x3c9ebe0a15c9bebc,
		0x431d67c49c100d4c,
		0x4cc5d4becb3e42b6,
		0x597f299cfc657e2a,
		0x5fcb6fab3ad6faec,
		0x6c44198c4a475817,
	}

	// ErrInputSizeLarge is returned if the size of input is too large
	ErrInputSizeLarge = errors.New("large input")
)
View Source
var (
	Type_name = map[int32]string{
		0: "Initial",
		1: "OtReceiver",
		2: "OtSendResponse",
		3: "EncH",
		4: "Sh2Hash",
	}
	Type_value = map[string]int32{
		"Initial":        0,
		"OtReceiver":     1,
		"OtSendResponse": 2,
		"EncH":           3,
		"Sh2Hash":        4,
	}
)

Enum value maps for Type.

View Source
var (

	// ErrNonHardenedKey is returned the index < MinHardenKey
	ErrNonHardenedKey = errors.New("the index can not produce any hardened key")
	// ErrHardenedKey is returned the index >= MinHardenKey
	ErrHardenedKey = errors.New("the index can not produce any nonhardened key")
	// ErrInvalidTranslation is invalid translate
	ErrInvalidTranslation = errors.New("invalid translate")
	// ErrIdentityChildPublicKey is the child public key is identity
	ErrIdentityChildPublicKey = errors.New("identity child public key")
	// ErrNotCorrectShare is the share value is invalid
	ErrNotCorrectShare = errors.New("the share value is invalid")
)
View Source
var (
	ErrNotReady = errors.New("not ready")
)
View Source
var File_github_com_getamis_alice_crypto_bip32_child_message_proto protoreflect.FileDescriptor

Functions

func NewHmacSha512

func NewHmacSha512(key []byte) *hmacSHA512

func NewShareManager

func NewShareManager(share *big.Int, pubKey *ecpointgrouplaw.ECPoint, chainCode []byte, depth byte, bks map[string]*birkhoffinterpolation.BkParameter, selfId string) (*shareManager, error)

func Sha512Compression

func Sha512Compression(p []byte, preState []uint64) []uint64

WARN: p is bit-Slice

func Sha512GetBlockWithPadding

func Sha512GetBlockWithPadding(p []byte) ([]byte, error)

Types

type BodyEncH

type BodyEncH struct {
	EncH []byte `protobuf:"bytes,1,opt,name=encH,proto3" json:"encH,omitempty"`
	// contains filtered or unexported fields
}

func (*BodyEncH) Descriptor deprecated

func (*BodyEncH) Descriptor() ([]byte, []int)

Deprecated: Use BodyEncH.ProtoReflect.Descriptor instead.

func (*BodyEncH) GetEncH

func (x *BodyEncH) GetEncH() []byte

func (*BodyEncH) ProtoMessage

func (*BodyEncH) ProtoMessage()

func (*BodyEncH) ProtoReflect

func (x *BodyEncH) ProtoReflect() protoreflect.Message

func (*BodyEncH) Reset

func (x *BodyEncH) Reset()

func (*BodyEncH) String

func (x *BodyEncH) String() string

type BodyInitial

type BodyInitial struct {
	OtRecMsg       *ot.OtReceiverMessage         `protobuf:"bytes,1,opt,name=otRecMsg,proto3" json:"otRecMsg,omitempty"`
	GarcirMsg      *circuit.GarbleCircuitMessage `protobuf:"bytes,2,opt,name=garcirMsg,proto3" json:"garcirMsg,omitempty"`
	OtherInfoWire  [][]byte                      `protobuf:"bytes,3,rep,name=otherInfoWire,proto3" json:"otherInfoWire,omitempty"`
	PubKey         []byte                        `protobuf:"bytes,4,opt,name=pubKey,proto3" json:"pubKey,omitempty"`
	PubKeyN        []byte                        `protobuf:"bytes,5,opt,name=pubKeyN,proto3" json:"pubKeyN,omitempty"`
	ShareGProofMsg *zkproof.SchnorrProofMessage  `protobuf:"bytes,6,opt,name=shareGProofMsg,proto3" json:"shareGProofMsg,omitempty"`
	// contains filtered or unexported fields
}

func (*BodyInitial) Descriptor deprecated

func (*BodyInitial) Descriptor() ([]byte, []int)

Deprecated: Use BodyInitial.ProtoReflect.Descriptor instead.

func (*BodyInitial) GetGarcirMsg

func (x *BodyInitial) GetGarcirMsg() *circuit.GarbleCircuitMessage

func (*BodyInitial) GetOtRecMsg

func (x *BodyInitial) GetOtRecMsg() *ot.OtReceiverMessage

func (*BodyInitial) GetOtherInfoWire

func (x *BodyInitial) GetOtherInfoWire() [][]byte

func (*BodyInitial) GetPubKey

func (x *BodyInitial) GetPubKey() []byte

func (*BodyInitial) GetPubKeyN

func (x *BodyInitial) GetPubKeyN() []byte

func (*BodyInitial) GetShareGProofMsg

func (x *BodyInitial) GetShareGProofMsg() *zkproof.SchnorrProofMessage

func (*BodyInitial) ProtoMessage

func (*BodyInitial) ProtoMessage()

func (*BodyInitial) ProtoReflect

func (x *BodyInitial) ProtoReflect() protoreflect.Message

func (*BodyInitial) Reset

func (x *BodyInitial) Reset()

func (*BodyInitial) String

func (x *BodyInitial) String() string

type BodyOtReceiver

type BodyOtReceiver struct {
	OtExtReceiveMsg *ot.OtExtReceiveMessage `protobuf:"bytes,1,opt,name=otExtReceiveMsg,proto3" json:"otExtReceiveMsg,omitempty"`
	// contains filtered or unexported fields
}

func (*BodyOtReceiver) Descriptor deprecated

func (*BodyOtReceiver) Descriptor() ([]byte, []int)

Deprecated: Use BodyOtReceiver.ProtoReflect.Descriptor instead.

func (*BodyOtReceiver) GetOtExtReceiveMsg

func (x *BodyOtReceiver) GetOtExtReceiveMsg() *ot.OtExtReceiveMessage

func (*BodyOtReceiver) ProtoMessage

func (*BodyOtReceiver) ProtoMessage()

func (*BodyOtReceiver) ProtoReflect

func (x *BodyOtReceiver) ProtoReflect() protoreflect.Message

func (*BodyOtReceiver) Reset

func (x *BodyOtReceiver) Reset()

func (*BodyOtReceiver) String

func (x *BodyOtReceiver) String() string

type BodyOtSendResponse

type BodyOtSendResponse struct {
	OtExtSendResponseMsg *ot.OtExtSendResponseMessage `protobuf:"bytes,1,opt,name=otExtSendResponseMsg,proto3" json:"otExtSendResponseMsg,omitempty"`
	// contains filtered or unexported fields
}

func (*BodyOtSendResponse) Descriptor deprecated

func (*BodyOtSendResponse) Descriptor() ([]byte, []int)

Deprecated: Use BodyOtSendResponse.ProtoReflect.Descriptor instead.

func (*BodyOtSendResponse) GetOtExtSendResponseMsg

func (x *BodyOtSendResponse) GetOtExtSendResponseMsg() *ot.OtExtSendResponseMessage

func (*BodyOtSendResponse) ProtoMessage

func (*BodyOtSendResponse) ProtoMessage()

func (*BodyOtSendResponse) ProtoReflect

func (x *BodyOtSendResponse) ProtoReflect() protoreflect.Message

func (*BodyOtSendResponse) Reset

func (x *BodyOtSendResponse) Reset()

func (*BodyOtSendResponse) String

func (x *BodyOtSendResponse) String() string

type BodySh2Hash

type BodySh2Hash struct {
	Result  []byte `protobuf:"bytes,1,opt,name=result,proto3" json:"result,omitempty"`
	Sh2Hash []byte `protobuf:"bytes,2,opt,name=sh2Hash,proto3" json:"sh2Hash,omitempty"`
	// contains filtered or unexported fields
}

func (*BodySh2Hash) Descriptor deprecated

func (*BodySh2Hash) Descriptor() ([]byte, []int)

Deprecated: Use BodySh2Hash.ProtoReflect.Descriptor instead.

func (*BodySh2Hash) GetResult

func (x *BodySh2Hash) GetResult() []byte

func (*BodySh2Hash) GetSh2Hash

func (x *BodySh2Hash) GetSh2Hash() []byte

func (*BodySh2Hash) ProtoMessage

func (*BodySh2Hash) ProtoMessage()

func (*BodySh2Hash) ProtoReflect

func (x *BodySh2Hash) ProtoReflect() protoreflect.Message

func (*BodySh2Hash) Reset

func (x *BodySh2Hash) Reset()

func (*BodySh2Hash) String

func (x *BodySh2Hash) String() string

type Child

type Child struct {
	*message.MsgMain
	// contains filtered or unexported fields
}

func NewAlice

func NewAlice(peerManager types.PeerManager, sid []uint8, share *big.Int, bks map[string]*birkhoffinterpolation.BkParameter, path string, chainCode []byte, depth uint8, childIndex uint32, pubKey *ecpointgrouplaw.ECPoint, listener types.StateChangedListener) (*Child, error)

func NewBob

func NewBob(peerManager types.PeerManager, sid []uint8, share *big.Int, bks map[string]*birkhoffinterpolation.BkParameter, path string, chainCode []byte, depth uint8, childIndex uint32, pubKey *ecpointgrouplaw.ECPoint, listener types.StateChangedListener) (*Child, error)

func (*Child) GetResult

func (m *Child) GetResult() (*Result, error)

func (*Child) Start

func (m *Child) Start()

type Message

type Message struct {
	Type Type   `protobuf:"varint,1,opt,name=type,proto3,enum=getamis.alice.crypto.bip32.child.Type" json:"type,omitempty"`
	Id   string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	// Types that are assignable to Body:
	//	*Message_Initial
	//	*Message_OtReceiver
	//	*Message_OtSendResponse
	//	*Message_EncH
	//	*Message_Sh2Hash
	Body isMessage_Body `protobuf_oneof:"body"`
	// contains filtered or unexported fields
}

func (*Message) Descriptor deprecated

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetBody

func (m *Message) GetBody() isMessage_Body

func (*Message) GetEncH

func (x *Message) GetEncH() *BodyEncH

func (*Message) GetId

func (x *Message) GetId() string

func (*Message) GetInitial

func (x *Message) GetInitial() *BodyInitial

func (*Message) GetMessageType

func (m *Message) GetMessageType() types.MessageType

func (*Message) GetOtReceiver

func (x *Message) GetOtReceiver() *BodyOtReceiver

func (*Message) GetOtSendResponse

func (x *Message) GetOtSendResponse() *BodyOtSendResponse

func (*Message) GetSh2Hash

func (x *Message) GetSh2Hash() *BodySh2Hash

func (*Message) GetType

func (x *Message) GetType() Type

func (*Message) IsValid

func (m *Message) IsValid() bool

func (*Message) ProtoMessage

func (*Message) ProtoMessage()

func (*Message) ProtoReflect

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Reset

func (x *Message) Reset()

func (*Message) String

func (x *Message) String() string

type Message_EncH

type Message_EncH struct {
	EncH *BodyEncH `protobuf:"bytes,6,opt,name=encH,proto3,oneof"`
}

type Message_Initial

type Message_Initial struct {
	Initial *BodyInitial `protobuf:"bytes,3,opt,name=initial,proto3,oneof"`
}

type Message_OtReceiver

type Message_OtReceiver struct {
	OtReceiver *BodyOtReceiver `protobuf:"bytes,4,opt,name=otReceiver,proto3,oneof"`
}

type Message_OtSendResponse

type Message_OtSendResponse struct {
	OtSendResponse *BodyOtSendResponse `protobuf:"bytes,5,opt,name=otSendResponse,proto3,oneof"`
}

type Message_Sh2Hash

type Message_Sh2Hash struct {
	Sh2Hash *BodySh2Hash `protobuf:"bytes,7,opt,name=sh2Hash,proto3,oneof"`
}

type Result

type Result struct {
	Translate *big.Int
	PublicKey *ecpointgrouplaw.ECPoint
	ChainCode []byte
	Depth     byte
}

type Type

type Type int32
const (
	Type_Initial        Type = 0
	Type_OtReceiver     Type = 1
	Type_OtSendResponse Type = 2
	Type_EncH           Type = 3
	Type_Sh2Hash        Type = 4
)

func (Type) Descriptor

func (Type) Descriptor() protoreflect.EnumDescriptor

func (Type) Enum

func (x Type) Enum() *Type

func (Type) EnumDescriptor deprecated

func (Type) EnumDescriptor() ([]byte, []int)

Deprecated: Use Type.Descriptor instead.

func (Type) Number

func (x Type) Number() protoreflect.EnumNumber

func (Type) String

func (x Type) String() string

func (Type) Type

func (Type) Type() protoreflect.EnumType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL