Documentation ¶
Overview ¶
Package urs implements Unique Ring Signatures, as defined in short version: http://csiflabs.cs.ucdavis.edu/~hbzhang/romring.pdf full version: http://eprint.iacr.org/2012/577.pdf
Index ¶
- func Base582Hex(b string) []byte
- func BlindVerify(R *PublicKeyRing, m []byte, rs *BlindRingSign) bool
- func CmpPubKey(i, j *ecdsa.PublicKey) bool
- func GenerateKey(c elliptic.Curve, rand io.Reader) (priv *ecdsa.PrivateKey, err error)
- func GetBinaryFileData(filename string) ([]byte, error)
- func GetSigFileData(filename string) ([]byte, error)
- func GetTextFileData(filename string) ([]byte, error)
- func Hex2Base58Str(val []byte) string
- func Hex2Base58String(val []byte) string
- func Hex2Big(b []byte) *big.Int
- func PubKeyToString(k ecdsa.PublicKey) string
- func ReadKeyPair(filename string) (*ecdsa.PrivateKey, error)
- func String2Hex(s string) []byte
- func StripTextFile(b []byte) []byte
- func TestBase58()
- func Verify(R *PublicKeyRing, m []byte, rs *RingSign) bool
- type Base58
- type BlindRingSign
- type PublicKeyRing
- type RingSign
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BlindVerify ¶
func BlindVerify(R *PublicKeyRing, m []byte, rs *BlindRingSign) bool
BlindVerify verifies the signature in rs of m using the public key ring, R. Its return value records whether the signature is valid.
func CmpPubKey ¶
CmpPubKey compares two pubkeys and returns true if they are the same, else false. WARNING: Assumes the curves are equivalent!
func GenerateKey ¶
GenerateKey generates a public and private key pair.
func GetBinaryFileData ¶
GetBinaryFileData retrieves the []byte encoding of a binary file from a path. It hashes the data it obtains sequentially to compress the file.
func GetSigFileData ¶
GetSigFileData retrieves the []byte encoding of a signature file from a path.
func GetTextFileData ¶
GetTextFileData retrieves the []byte encoding of a text file from a path.
func Hex2Base58Str ¶
func Hex2Base58String ¶
func PubKeyToString ¶
func ReadKeyPair ¶
func ReadKeyPair(filename string) (*ecdsa.PrivateKey, error)
ReadKeyPair reads an ECDSA keypair a file in JSON object format. Example JSON input:
{ "privkey": "..." }
It also checks if a pubkey is in the keyring and, if not, appends it to the keyring.
func String2Hex ¶
func StripTextFile ¶
StripTextFile removes line breaks from a text file to ensure that signatures of text files function correctly cross platform.
Types ¶
type Base58 ¶
type Base58 string
type to hold the Base58 string
func StrHex2Base58 ¶
func String2Base58 ¶
func StringHex2Base58 ¶
encodes string stored hex bytes into base58
func (Base58) Base582Big ¶
type BlindRingSign ¶
type BlindRingSign struct {
KX, KY *big.Int
X, Y *big.Int
C, T []*big.Int
// contains filtered or unexported fields
}
func BlindSign ¶
func BlindSign(rand io.Reader, priv *ecdsa.PrivateKey, R *PublicKeyRing, m []byte) (rs *BlindRingSign, err error)
BlindSign signs an arbitrary length message (which should NOT be the hash of a larger message) using the private key, priv and the public key ring, R. It returns the signature as a struct of type RingSign. The security of the private key depends on the entropy of rand. The public keys in the ring must all be using the same curve.
func (*BlindRingSign) FromBase58 ¶
func (k *BlindRingSign) FromBase58(sig string) error
FromBase58 returns a ring signature from a Base58 string, to the RingSign struct.
func (*BlindRingSign) ToBase58 ¶
func (k *BlindRingSign) ToBase58() string
ToBase58 returns a ring signature as a Base58 string.
type PublicKeyRing ¶
PublicKeyRing is a list of public keys.
func NewPublicKeyRing ¶
func NewPublicKeyRing(cap uint) *PublicKeyRing
NewPublicKeyRing creates a new public key ring. All keys added to the ring must use the same curve.
func ReadKeyRing ¶
func ReadKeyRing(filename string, kp *ecdsa.PrivateKey) (*PublicKeyRing, error)
ReadKeyRing reads a key ring of public keys from a file in JSON object format, and also inserts the pubkey of a keypair if it's not already present (handles bug in URS implementation).
func (*PublicKeyRing) Add ¶
func (r *PublicKeyRing) Add(pub ecdsa.PublicKey)
Add adds a public key, pub to the ring. All keys added to the ring must use the same curve.
func (*PublicKeyRing) Bytes ¶
func (r *PublicKeyRing) Bytes() (b []byte)
Bytes returns the public key ring as a byte slice.
func (*PublicKeyRing) Less ¶
func (r *PublicKeyRing) Less(i, j int) bool
Less determines which of two []ecdsa.PublicKey X values is smaller; if they are the same, evaluate the Y values instead.
func (*PublicKeyRing) Swap ¶
func (r *PublicKeyRing) Swap(i, j int)
Swap swaps two []ecdsa.PublicKey values.
type RingSign ¶
func Sign ¶
func Sign(rand io.Reader, priv *ecdsa.PrivateKey, R *PublicKeyRing, m []byte) (rs *RingSign, err error)
Sign signs an arbitrary length message (which should NOT be the hash of a larger message) using the private key, priv and the public key ring, R. It returns the signature as a struct of type RingSign. The security of the private key depends on the entropy of rand. The public keys in the ring must all be using the same curve.
func (*RingSign) FromBase58 ¶
FromBase58 returns a ring signature from a Base58 string, to the RingSign struct.