Documentation ¶
Index ¶
- Constants
- Variables
- func BuffToInt(buff []byte) *big.Int
- func CreateOID(s string) asn1.ObjectIdentifier
- func CurveHashSupportedCombination(curve func() elliptic.Curve, hasher func() hash.Hash) bool
- func CurvePolynomial(params *elliptic.CurveParams, x *big.Int) *big.Int
- func GetCurve(oid asn1.ObjectIdentifier) (func() elliptic.Curve, bool)
- func GetCurveName(curve elliptic.Curve) string
- func GetCurveOID(curve func() elliptic.Curve) (asn1.ObjectIdentifier, int)
- func GetCurveOIDForCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, int)
- func GetHasher(oid asn1.ObjectIdentifier) (func() hash.Hash, bool)
- func GetHasherName(fnc func() hash.Hash) string
- func GetHasherOID(fnc func() hash.Hash) (asn1.ObjectIdentifier, int)
- func GetZinv(curveName string) (*big.Int, *big.Int)
- func PointsToBytes(points []Point) []byte
- func Verify(sign *Signature, publicKeys []*ecdsa.PublicKey, message []byte, ...) int
- type FactoryContext
- func (fc FactoryContext) FindPointOnCurve(value *big.Int) (*big.Int, *big.Int)
- func (fc FactoryContext) HashPublicKeysIntoPoint(publicKeyPoints []Point, caseIdentifier []byte) Point
- func (fc FactoryContext) MakeDigest(data []byte) []byte
- func (fc FactoryContext) PointAdd(p1, p2 Point) Point
- func (fc FactoryContext) PointScalarMult(p Point, n []byte) Point
- type FoldedPublicKeys
- type Point
- type PointData
- type Signature
- type Zinv
Constants ¶
const ( Origin = "github.com/zbohm/lirisi" SignatureVersion = 1 Success = 0 PrivateKeyNotFitPublic = 1 InsufficientNumberOfPublicKeys = 2 PrivateKeyPositionOutOfRange = 3 PrivateKeyNotFoundAmongPublicKeys = 4 UnexpectedCurveType = 5 UnexpectedHashType = 6 IncorrectNumberOfSignatures = 7 InvalidKeyImage = 8 IncorrectChecksum = 9 OIDHasherNotFound = 10 OIDCurveNotFound = 11 UnsupportedCurveHashCombination = 12 PointWasNotFound = 13 DecodePEMFailure = 14 UnexpectedRestOfSignature = 15 Asn1MarshalFailed = 16 EncodePEMFailed = 17 InvalidPointCoordinates = 18 NilPointCoordinates = 19 ParseECPrivateKeyFailure = 20 Asn1UnmarshalFailed = 21 MarshalPKIXPublicKeyFailed = 22 ParsePKIXPublicKeyFailed = 23 CreateKeyFailed = 24 MarshalKeyFailed = 25 )
Status codes for sign/verify functions.
const LirisiVersion = "0.0.1"
Lirisi application version.
Variables ¶
var BrainpoolParentCurves = map[string]func() elliptic.Curve{ "brainpoolP256r1": brainpool.P256t1, "brainpoolP384r1": brainpool.P384t1, "brainpoolP512r1": brainpool.P512t1, }
BrainpoolParentCurves maps twisted curves with untwisted parents.
var BrainpoolZ = map[string]string{
"brainpoolP256r1": "3E2D4BD9597B58639AE7AA669CAB9837CF5CF20A2C852D10F655668DFC150EF0",
"brainpoolP384r1": "41DFE8DD399331F7166A66076734A89CD0D2BCDB7D068E44E1F378F41ECBAE97D2D63DBC87BCCDDCCC5DA39E8589291C",
"brainpoolP512r1": "12EE58E6764838B69782136F0F2D3BA06E27695716054092E60A80BEDB212B64E585D90BCE13761F85C3F1D2A64E3BE8FEA2220F01EBA5EEB0F35DBD29D922AB",
}
BrainpoolZ maps Z values required by GetZinv for function fromTwisted.
var BrainpoolZinv = map[string]Zinv{}
BrainpoolZinv inverzed Zinv.
var CurveCodes = map[string]func() elliptic.Curve{ "secp224r1": elliptic.P224, "prime256v1": elliptic.P256, "secp384r1": elliptic.P384, "secp521r1": elliptic.P521, "brainpoolP256r1": brainpool.P256r1, "brainpoolP256t1": brainpool.P256t1, "brainpoolP384r1": brainpool.P384r1, "brainpoolP384t1": brainpool.P384t1, "brainpoolP512r1": brainpool.P512r1, "brainpoolP512t1": brainpool.P512t1, "secp256k1": crypto.S256, }
CurveCodes maps curve names to curves available to make signature.
var ErrorMessages = map[int]string{ PrivateKeyNotFitPublic: "Private key not fit public.", InsufficientNumberOfPublicKeys: "Insufficient number of public keys.", PrivateKeyPositionOutOfRange: "Private key position out of range.", PrivateKeyNotFoundAmongPublicKeys: "Private key not found among public keys.", UnexpectedCurveType: "Unexpected curve type.", UnexpectedHashType: "Unexpected hash type.", IncorrectNumberOfSignatures: "Incorrect number of signatures.", InvalidKeyImage: "Invalid key image.", IncorrectChecksum: "Incorrect checksum.", OIDHasherNotFound: "OID hasher not found.", OIDCurveNotFound: "OID curve not found.", UnsupportedCurveHashCombination: "Unsupported curve hash combination.", PointWasNotFound: "A point on the curve was not found. Please try another case identigier.", DecodePEMFailure: "Decode PEM failed.", UnexpectedRestOfSignature: "Unexpected rest at the end of signature.", Asn1MarshalFailed: "ASN1 Marshal failed.", EncodePEMFailed: "PEM Encode failed.", InvalidPointCoordinates: "Invalid point coordinates.", NilPointCoordinates: "Nil point coordinates.", ParseECPrivateKeyFailure: "Parse EC private key failed.", Asn1UnmarshalFailed: "ASN1 Unmarshal Failed.", MarshalPKIXPublicKeyFailed: "Marshal PKIX public key falied.", ParsePKIXPublicKeyFailed: "Parse PKIX public key falied.", CreateKeyFailed: "Create key failed.", MarshalKeyFailed: "Marshal key failed.", }
ErrorMessages convert status codes to human readable error messages.
var HashCodes = map[string]func() hash.Hash{ "sha3-224": sha3.New224, "sha3-256": sha3.New256, "sha3-384": sha3.New384, "sha3-512": sha3.New512, }
HashCodes maps hash names to hash functions available to make signature. printf "test" | openssl dgst -sha3-256
var OIDCurves = map[string]func() elliptic.Curve{ "1.3.132.0.33": elliptic.P224, "1.2.840.10045.3.1.7": elliptic.P256, "1.3.132.0.34": elliptic.P384, "1.3.132.0.35": elliptic.P521, "1.3.36.3.3.2.8.1.1.7": brainpool.P256r1, "1.3.36.3.3.2.8.1.1.8": brainpool.P256t1, "1.3.36.3.3.2.8.1.1.11": brainpool.P384r1, "1.3.36.3.3.2.8.1.1.12": brainpool.P384t1, "1.3.36.3.3.2.8.1.1.13": brainpool.P512r1, "1.3.36.3.3.2.8.1.1.14": brainpool.P512t1, "1.3.132.0.10": crypto.S256, }
OIDCurves - Object identifier standardized by ITU.
var OIDHashers = map[string]func() hash.Hash{ "2.16.840.1.101.3.4.2.7": sha3.New224, "2.16.840.1.101.3.4.2.8": sha3.New256, "2.16.840.1.101.3.4.2.9": sha3.New384, "2.16.840.1.101.3.4.2.10": sha3.New512, }
OIDHashers - Object identifier standardized by ITU.
var TwistedCurves = map[string]func() elliptic.Curve{ "brainpoolP256r1": brainpool.P256r1, "brainpoolP384r1": brainpool.P384r1, "brainpoolP512r1": brainpool.P512r1, }
TwistedCurves maps curve names to twisted curves.
Functions ¶
func CreateOID ¶
func CreateOID(s string) asn1.ObjectIdentifier
CreateOID creates asn1.ObjectIdentifier
func CurveHashSupportedCombination ¶
CurveHashSupportedCombination returns true if the curve and hash combination are supported.
func CurvePolynomial ¶
CurvePolynomial returns y calculaged from x. For curves is: (x³ - 3x + B) % P or (x³ - 3x) % P For Secp256k1 is: (x³ + B) % P
func GetCurve ¶
func GetCurve(oid asn1.ObjectIdentifier) (func() elliptic.Curve, bool)
GetCurve returns hash function and error.
func GetCurveName ¶
GetCurveName returns curve name of the curve instace.
func GetCurveOID ¶
func GetCurveOID(curve func() elliptic.Curve) (asn1.ObjectIdentifier, int)
GetCurveOID return OID of elliptic curve.
func GetCurveOIDForCurve ¶
func GetCurveOIDForCurve(curve elliptic.Curve) (asn1.ObjectIdentifier, int)
GetCurveOIDForCurve return OID of elliptic curve instance.
func GetHasher ¶
func GetHasher(oid asn1.ObjectIdentifier) (func() hash.Hash, bool)
GetHasher returns hash function and error.
func GetHasherName ¶
GetHasherName returns name of hash function.
func GetHasherOID ¶
func GetHasherOID(fnc func() hash.Hash) (asn1.ObjectIdentifier, int)
GetHasherOID return OID of hash function.
func PointsToBytes ¶
PointsToBytes converts Points to bytes.
Types ¶
type FactoryContext ¶
FactoryContext holds curve object and hash function.
func (FactoryContext) FindPointOnCurve ¶
FindPointOnCurve finds point x,y on the curve.
func (FactoryContext) HashPublicKeysIntoPoint ¶
func (fc FactoryContext) HashPublicKeysIntoPoint(publicKeyPoints []Point, caseIdentifier []byte) Point
HashPublicKeysIntoPoint returns a point on the curve created from public keys in this way:
func (FactoryContext) MakeDigest ¶
func (fc FactoryContext) MakeDigest(data []byte) []byte
MakeDigest makes hash digest from data.
func (FactoryContext) PointAdd ¶
func (fc FactoryContext) PointAdd(p1, p2 Point) Point
PointAdd provide add points over elliptic curve.
func (FactoryContext) PointScalarMult ¶
func (fc FactoryContext) PointScalarMult(p Point, n []byte) Point
PointScalarMult provide scalar multiplication over elliptic curve.
type FoldedPublicKeys ¶
type FoldedPublicKeys struct { Name string CurveOID asn1.ObjectIdentifier HasherOID asn1.ObjectIdentifier Digest []byte Keys [][]byte }
FoldedPublicKeys holds data of points of public keys.
type Point ¶
type Point struct {
// contains filtered or unexported fields
}
Point on elliptic curve.
func ConvertPublicKeysToPoints ¶
ConvertPublicKeysToPoints converts public keys into Points.
type PointData ¶
PointData holds X,Y coordinates of point. https://tools.ietf.org/html/rfc5480#section-2.2 ECPoint ::= OCTET STRING
type Signature ¶
type Signature struct { Name string Version int CurveOID asn1.ObjectIdentifier HasherOID asn1.ObjectIdentifier KeyImage PointData Checksum []byte Signatures [][]byte }
Signature holds data of ring signature.