Documentation ¶
Overview ¶
A Go implementation of PASETO. Paseto is everything you love about JOSE (JWT, JWE, JWS) without any of the many design deficits that plague the JOSE standards.
Index ¶
- Variables
- type Parser
- func (p *Parser) AddRule(rule ...Rule)
- func (p Parser) ParseV2Local(key V2SymmetricKey, tainted string) (*Token, error)
- func (p Parser) ParseV2Public(key V2AsymmetricPublicKey, tainted string) (*Token, error)
- func (p Parser) ParseV3Local(key V3SymmetricKey, tainted string, implicit []byte) (*Token, error)
- func (p Parser) ParseV3Public(key V3AsymmetricPublicKey, tainted string, implicit []byte) (*Token, error)
- func (p Parser) ParseV4Local(key V4SymmetricKey, tainted string, implicit []byte) (*Token, error)
- func (p Parser) ParseV4Public(key V4AsymmetricPublicKey, tainted string, implicit []byte) (*Token, error)
- func (p *Parser) SetRules(rules []Rule)
- func (p Parser) UnsafeParseFooter(protocol Protocol, tainted string) ([]byte, error)
- type Protocol
- type Purpose
- type Rule
- type RuleError
- type Token
- func (t Token) Claims() map[string]interface{}
- func (token Token) ClaimsJSON() []byte
- func (t Token) Footer() []byte
- func (t Token) Get(key string, output interface{}) (err error)
- func (t Token) GetAudience() (string, error)
- func (t Token) GetExpiration() (time.Time, error)
- func (t Token) GetIssuedAt() (time.Time, error)
- func (t Token) GetIssuer() (string, error)
- func (t Token) GetJti() (string, error)
- func (t Token) GetNotBefore() (time.Time, error)
- func (t Token) GetString(key string) (string, error)
- func (t Token) GetSubject() (string, error)
- func (t Token) GetTime(key string) (time.Time, error)
- func (token *Token) Set(key string, value interface{}) error
- func (t *Token) SetAudience(audience string)
- func (t *Token) SetExpiration(exp time.Time)
- func (t *Token) SetFooter(footer []byte)
- func (t *Token) SetIssuedAt(iat time.Time)
- func (t *Token) SetIssuer(issuer string)
- func (t *Token) SetJti(identifier string)
- func (t *Token) SetNotBefore(nbf time.Time)
- func (t *Token) SetString(key string, value string)
- func (t *Token) SetSubject(subject string)
- func (t *Token) SetTime(key string, value time.Time)
- func (t Token) V2Encrypt(key V2SymmetricKey) string
- func (t Token) V2Sign(key V2AsymmetricSecretKey) string
- func (t Token) V3Encrypt(key V3SymmetricKey, implicit []byte) string
- func (t Token) V3Sign(key V3AsymmetricSecretKey, implicit []byte) string
- func (t Token) V4Encrypt(key V4SymmetricKey, implicit []byte) string
- func (t Token) V4Sign(key V4AsymmetricSecretKey, implicit []byte) string
- type TokenError
- type V2AsymmetricPublicKey
- type V2AsymmetricSecretKey
- func NewV2AsymmetricSecretKey() V2AsymmetricSecretKey
- func NewV2AsymmetricSecretKeyFromBytes(privateKey []byte) (V2AsymmetricSecretKey, error)
- func NewV2AsymmetricSecretKeyFromEd25519(privateKey ed25519.PrivateKey) (V2AsymmetricSecretKey, error)
- func NewV2AsymmetricSecretKeyFromHex(hexEncoded string) (V2AsymmetricSecretKey, error)
- func NewV2AsymmetricSecretKeyFromSeed(hexEncoded string) (V2AsymmetricSecretKey, error)
- type V2SymmetricKey
- type V3AsymmetricPublicKey
- type V3AsymmetricSecretKey
- func NewV3AsymmetricSecretKey() V3AsymmetricSecretKey
- func NewV3AsymmetricSecretKeyFromBytes(secretBytes []byte) (V3AsymmetricSecretKey, error)
- func NewV3AsymmetricSecretKeyFromEcdsa(privateKey ecdsa.PrivateKey) (V3AsymmetricSecretKey, error)
- func NewV3AsymmetricSecretKeyFromHex(hexEncoded string) (V3AsymmetricSecretKey, error)
- type V3SymmetricKey
- type V4AsymmetricPublicKey
- type V4AsymmetricSecretKey
- func NewV4AsymmetricSecretKey() V4AsymmetricSecretKey
- func NewV4AsymmetricSecretKeyFromBytes(privateKey []byte) (V4AsymmetricSecretKey, error)
- func NewV4AsymmetricSecretKeyFromEd25519(privateKey ed25519.PrivateKey) (V4AsymmetricSecretKey, error)
- func NewV4AsymmetricSecretKeyFromHex(hexEncoded string) (V4AsymmetricSecretKey, error)
- func NewV4AsymmetricSecretKeyFromSeed(hexEncoded string) (V4AsymmetricSecretKey, error)
- type V4SymmetricKey
- type Version
Constants ¶
This section is empty.
Variables ¶
var ( // V2Local represents a v2 protocol in local mode V2Local = Protocol{Version2, Local} // V2Public represents a v2 protocol in public mode V2Public = Protocol{Version2, Public} // V3Local represents a v3 protocol in local mode V3Local = Protocol{Version3, Local} // V3Public represents a v3 protocol in public mode V3Public = Protocol{Version3, Public} // V4Local represents a v4 protocol in local mode V4Local = Protocol{Version4, Local} // V4Public represents a v4 protocol in public mode V4Public = Protocol{Version4, Public} )
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser is used to verify or decrypt a token, and can be provided with a set of rules.
func MakeParser ¶
MakeParser allows a parser to be constructed with a specified set of rules.
func NewParserForValidNow ¶
func NewParserForValidNow() Parser
NewParserForValidNow returns a parser that will require parsed tokens to be valid "now".
func NewParserWithoutExpiryCheck ¶
func NewParserWithoutExpiryCheck() Parser
NewParserWithoutExpiryCheck returns a parser with no currently set rules.
func (Parser) ParseV2Local ¶
func (p Parser) ParseV2Local(key V2SymmetricKey, tainted string) (*Token, error)
ParseV2Local will parse and decrypt a v2 local paseto and validate against any parser rules. Error if parsing, decryption, or any rule fails.
func (Parser) ParseV2Public ¶
func (p Parser) ParseV2Public(key V2AsymmetricPublicKey, tainted string) (*Token, error)
ParseV2Public will parse and verify a v2 public paseto and validate against any parser rules. Error if parsing, verification, or any rule fails.
func (Parser) ParseV3Local ¶
ParseV3Local will parse and decrypt a v3 local paseto and validate against any parser rules. Error if parsing, decryption, or any rule fails.
func (Parser) ParseV3Public ¶ added in v1.1.0
func (p Parser) ParseV3Public(key V3AsymmetricPublicKey, tainted string, implicit []byte) (*Token, error)
ParseV3Public will parse and verify a v3 public paseto and validate against any parser rules. Error if parsing, verification, or any rule fails.
func (Parser) ParseV4Local ¶
ParseV4Local will parse and decrypt a v4 local paseto and validate against any parser rules. Error if parsing, decryption, or any rule fails.
func (Parser) ParseV4Public ¶
func (p Parser) ParseV4Public(key V4AsymmetricPublicKey, tainted string, implicit []byte) (*Token, error)
ParseV4Public will parse and verify a v4 public paseto and validate against any parser rules. Error if parsing, verification, or any rule fails.
type Protocol ¶
type Protocol struct {
// contains filtered or unexported fields
}
Protocol represents a set of cryptographic operations for paseto
func NewProtocol ¶
NewProtocol creates a new protocol with a given version and purpose (both must be valid)
type Rule ¶
Rule validates a given token for certain required preconditions (defined by the rule itself). If validation fails a Rule MUST return an error, otherwise error MUST be nil.
func ForAudience ¶
ForAudience requires that the given audience matches the "aud" field of the token.
func IdentifiedBy ¶
IdentifiedBy requires that the given identifier matches the "jti" field of the token.
func NotBeforeNbf ¶ added in v1.1.3
func NotBeforeNbf() Rule
NotBeforeNbf requires that the token is allowed to be used according to the time when this rule is checked and the "nbf" field of a token. Beware that this rule does not validate the token's "iat" or "exp" fields, or even require their presence.
func NotExpired ¶
func NotExpired() Rule
NotExpired requires that the token has not expired according to the time when this rule is checked and the "exp" field of a token. Beware that this rule does not validate the token's "iat" or "nbf" fields, or even require their presence.
type RuleError ¶ added in v1.2.0
type RuleError struct {
// contains filtered or unexported fields
}
Any error which is the result of a rule failure (distinct from a TokenError) Can be used to detect cryptographically valid tokens which have failed only due to a rule failure: which may warrant a slightly different processing follow up.
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
Token is a set of paseto claims, and a footer
func NewTokenFromClaimsJSON ¶
NewTokenFromClaimsJSON parses the JSON using encoding/json in claimsData and returns a token with those claims, and the specified footer.
func (Token) ClaimsJSON ¶
ClaimsJSON gets the stored claims as JSON.
func (Token) Get ¶
Get gets the given key and writes the value into output (which should be a a pointer), if present by parsing the JSON using encoding/json.
func (Token) GetAudience ¶
GetAudience returns the token's "aud" field, or error if not found or not a string.
func (Token) GetExpiration ¶
GetExpiration returns the token's "exp" field, or error if not found or not a a RFC3339 compliant time.
func (Token) GetIssuedAt ¶
GetIssuedAt returns the token's "iat" field, or error if not found or not a a RFC3339 compliant time.
func (Token) GetIssuer ¶
GetIssuer returns the token's "iss" field, or error if not found or not a string.
func (Token) GetJti ¶
GetJti returns the token's "jti" field, or error if not found or not a string.
func (Token) GetNotBefore ¶
GetNotBefore returns the token's "nbf" field, or error if not found or not a a RFC3339 compliant time.
func (Token) GetString ¶
GetString returns the value for a given key as a string, or error if this is not possible (cannot be a string, or value does not exist)
func (Token) GetSubject ¶
GetSubject returns the token's "sub" field, or error if not found or not a string.
func (Token) GetTime ¶
GetTime returns the time for a given key as a string, or error if this is not possible (cannot parse as a time, or value does not exist)
func (*Token) Set ¶
Set sets the key with the specified value. Note that this value needs to be serialisable to JSON using encoding/json. Set will check this and return an error if it is not serialisable.
func (*Token) SetAudience ¶
SetAudience sets the token's "aud" field.
func (*Token) SetExpiration ¶
SetExpiration sets the token's "exp" field.
func (*Token) SetIssuedAt ¶
SetIssuedAt sets the token's "iat" field.
func (*Token) SetNotBefore ¶
SetNotBefore sets the token's "nbf" field.
func (*Token) SetString ¶
SetString sets the given key with value. If, for some reason, the provided string cannot be serialised as JSON SetString will panic.
func (*Token) SetSubject ¶
SetSubject sets the token's "sub" field.
func (*Token) SetTime ¶
SetTime sets the given key with the given time, encoded using RFC3339 (the time format used by common PASETO claims).
func (Token) V2Encrypt ¶
func (t Token) V2Encrypt(key V2SymmetricKey) string
V2Encrypt signs the token, using the given key.
func (Token) V2Sign ¶
func (t Token) V2Sign(key V2AsymmetricSecretKey) string
V2Sign signs the token, using the given key.
func (Token) V3Encrypt ¶
func (t Token) V3Encrypt(key V3SymmetricKey, implicit []byte) string
V3Encrypt signs the token, using the given key and implicit bytes. Implicit bytes are bytes used to calculate the encrypted token, but which are not present in the final token (or its decrypted value). Implicit must be reprovided for successful decryption, and can not be recovered.
func (Token) V3Sign ¶ added in v1.1.0
func (t Token) V3Sign(key V3AsymmetricSecretKey, implicit []byte) string
V3Sign signs the token, using the given key and implicit bytes. Implicit bytes are bytes used to calculate the signature, but which are not present in the final token. Implicit must be reprovided for successful verification, and can not be recovered.
func (Token) V4Encrypt ¶
func (t Token) V4Encrypt(key V4SymmetricKey, implicit []byte) string
V4Encrypt signs the token, using the given key and implicit bytes. Implicit bytes are bytes used to calculate the encrypted token, but which are not present in the final token (or its decrypted value). Implicit must be reprovided for successful decryption, and can not be recovered.
func (Token) V4Sign ¶
func (t Token) V4Sign(key V4AsymmetricSecretKey, implicit []byte) string
V4Sign signs the token, using the given key and implicit bytes. Implicit bytes are bytes used to calculate the signature, but which are not present in the final token. Implicit must be reprovided for successful verification, and can not be recovered.
type TokenError ¶ added in v1.2.0
type TokenError struct {
// contains filtered or unexported fields
}
Any cryptography issue (with the token) or formatting error. This does not include cryptography errors with input key material, these will return regular errors.
func (TokenError) Error ¶ added in v1.2.0
func (e TokenError) Error() string
func (TokenError) Is ¶ added in v1.2.0
func (_ TokenError) Is(e error) bool
func (TokenError) Unwrap ¶ added in v1.2.0
func (e TokenError) Unwrap() error
type V2AsymmetricPublicKey ¶
type V2AsymmetricPublicKey struct {
// contains filtered or unexported fields
}
V2AsymmetricPublicKey V2 public public key
func NewV2AsymmetricPublicKeyFromBytes ¶ added in v1.1.1
func NewV2AsymmetricPublicKeyFromBytes(publicKey []byte) (V2AsymmetricPublicKey, error)
NewV2AsymmetricPublicKeyFromBytes Construct a v2 public key from bytes
func NewV2AsymmetricPublicKeyFromEd25519 ¶ added in v1.5.0
func NewV2AsymmetricPublicKeyFromEd25519(publicKey ed25519.PublicKey) (V2AsymmetricPublicKey, error)
NewV2AsymmetricPublicKeyFromEd25519 Construct a v2 public key from a standard Go object
func NewV2AsymmetricPublicKeyFromHex ¶
func NewV2AsymmetricPublicKeyFromHex(hexEncoded string) (V2AsymmetricPublicKey, error)
NewV2AsymmetricPublicKeyFromHex Construct a v2 public key from hex
func (V2AsymmetricPublicKey) ExportBytes ¶ added in v1.1.1
func (k V2AsymmetricPublicKey) ExportBytes() []byte
ExportBytes export a V2AsymmetricPublicKey to raw byte array
func (V2AsymmetricPublicKey) ExportHex ¶
func (k V2AsymmetricPublicKey) ExportHex() string
ExportHex export a V2AsymmetricPublicKey to hex for storage
type V2AsymmetricSecretKey ¶
type V2AsymmetricSecretKey struct {
// contains filtered or unexported fields
}
V2AsymmetricSecretKey V2 public private key
func NewV2AsymmetricSecretKey ¶
func NewV2AsymmetricSecretKey() V2AsymmetricSecretKey
NewV2AsymmetricSecretKey generate a new secret key for use with asymmetric cryptography. Don't forget to export the public key for sharing, DO NOT share this secret key.
func NewV2AsymmetricSecretKeyFromBytes ¶ added in v1.1.1
func NewV2AsymmetricSecretKeyFromBytes(privateKey []byte) (V2AsymmetricSecretKey, error)
NewV2AsymmetricSecretKeyFromBytes creates a secret key from bytes
func NewV2AsymmetricSecretKeyFromEd25519 ¶ added in v1.5.0
func NewV2AsymmetricSecretKeyFromEd25519(privateKey ed25519.PrivateKey) (V2AsymmetricSecretKey, error)
NewV2AsymmetricSecretKeyFromEd25519 creates a secret key from a standard Go object
func NewV2AsymmetricSecretKeyFromHex ¶
func NewV2AsymmetricSecretKeyFromHex(hexEncoded string) (V2AsymmetricSecretKey, error)
NewV2AsymmetricSecretKeyFromHex creates a secret key from hex
func NewV2AsymmetricSecretKeyFromSeed ¶
func NewV2AsymmetricSecretKeyFromSeed(hexEncoded string) (V2AsymmetricSecretKey, error)
NewV2AsymmetricSecretKeyFromSeed creates a secret key from a seed (hex)
func (V2AsymmetricSecretKey) ExportBytes ¶ added in v1.1.1
func (k V2AsymmetricSecretKey) ExportBytes() []byte
ExportBytes export a V2AsymmetricSecretKey to raw byte array
func (V2AsymmetricSecretKey) ExportHex ¶
func (k V2AsymmetricSecretKey) ExportHex() string
ExportHex export a V2AsymmetricSecretKey to hex for storage
func (V2AsymmetricSecretKey) ExportSeedHex ¶
func (k V2AsymmetricSecretKey) ExportSeedHex() string
ExportSeedHex export a V2AsymmetricSecretKey's seed to hex for storage
func (V2AsymmetricSecretKey) Public ¶
func (k V2AsymmetricSecretKey) Public() V2AsymmetricPublicKey
Public returns the corresponding public key for a secret key
type V2SymmetricKey ¶
type V2SymmetricKey struct {
// contains filtered or unexported fields
}
V2SymmetricKey v2 local symmetric key
func NewV2SymmetricKey ¶
func NewV2SymmetricKey() V2SymmetricKey
NewV2SymmetricKey generates a new symmetric key for encryption
func V2SymmetricKeyFromBytes ¶ added in v1.1.1
func V2SymmetricKeyFromBytes(bytes []byte) (V2SymmetricKey, error)
V2SymmetricKeyFromBytes constructs a key from bytes
func V2SymmetricKeyFromHex ¶
func V2SymmetricKeyFromHex(hexEncoded string) (V2SymmetricKey, error)
V2SymmetricKeyFromHex constructs a key from hex
func (V2SymmetricKey) ExportBytes ¶ added in v1.1.1
func (k V2SymmetricKey) ExportBytes() []byte
ExportBytes exports the key as raw bytes
func (V2SymmetricKey) ExportHex ¶
func (k V2SymmetricKey) ExportHex() string
ExportHex exports the key as hex for storage
type V3AsymmetricPublicKey ¶ added in v1.1.0
type V3AsymmetricPublicKey struct {
// contains filtered or unexported fields
}
V3AsymmetricPublicKey v3 public public key
func NewV3AsymmetricPublicKeyFromBytes ¶ added in v1.1.1
func NewV3AsymmetricPublicKeyFromBytes(publicKeyBytes []byte) (V3AsymmetricPublicKey, error)
NewV3AsymmetricPublicKeyFromBytes Construct a v3 public key from bytes
func NewV3AsymmetricPublicKeyFromEcdsa ¶ added in v1.5.0
func NewV3AsymmetricPublicKeyFromEcdsa(publicKey ecdsa.PublicKey) (V3AsymmetricPublicKey, error)
NewV3AsymmetricPublicKeyFromEcdsa Construct a v3 public key from a standard Go object
func NewV3AsymmetricPublicKeyFromHex ¶ added in v1.1.0
func NewV3AsymmetricPublicKeyFromHex(hexEncoded string) (V3AsymmetricPublicKey, error)
NewV3AsymmetricPublicKeyFromHex Construct a v3 public key from hex
func (V3AsymmetricPublicKey) ExportBytes ¶ added in v1.1.1
func (k V3AsymmetricPublicKey) ExportBytes() []byte
ExportBytes export a V3AsymmetricPublicKey to raw byte array
func (V3AsymmetricPublicKey) ExportHex ¶ added in v1.1.0
func (k V3AsymmetricPublicKey) ExportHex() string
ExportHex export a V3AsymmetricPublicKey to hex for storage
type V3AsymmetricSecretKey ¶ added in v1.1.0
type V3AsymmetricSecretKey struct {
// contains filtered or unexported fields
}
V3AsymmetricSecretKey v3 public private key
func NewV3AsymmetricSecretKey ¶ added in v1.1.0
func NewV3AsymmetricSecretKey() V3AsymmetricSecretKey
NewV3AsymmetricSecretKey generate a new secret key for use with asymmetric cryptography. Don't forget to export the public key for sharing, DO NOT share this secret key.
func NewV3AsymmetricSecretKeyFromBytes ¶ added in v1.1.1
func NewV3AsymmetricSecretKeyFromBytes(secretBytes []byte) (V3AsymmetricSecretKey, error)
NewV3AsymmetricSecretKeyFromBytes creates a secret key from bytes
func NewV3AsymmetricSecretKeyFromEcdsa ¶ added in v1.5.0
func NewV3AsymmetricSecretKeyFromEcdsa(privateKey ecdsa.PrivateKey) (V3AsymmetricSecretKey, error)
NewV3AsymmetricSecretKeyFromBytes creates a secret key from a standard Go object
func NewV3AsymmetricSecretKeyFromHex ¶ added in v1.1.0
func NewV3AsymmetricSecretKeyFromHex(hexEncoded string) (V3AsymmetricSecretKey, error)
NewV3AsymmetricSecretKeyFromHex creates a secret key from hex
func (V3AsymmetricSecretKey) ExportBytes ¶ added in v1.1.1
func (k V3AsymmetricSecretKey) ExportBytes() []byte
ExportBytes export a V3AsymmetricSecretKey to raw byte array
func (V3AsymmetricSecretKey) ExportHex ¶ added in v1.1.0
func (k V3AsymmetricSecretKey) ExportHex() string
ExportHex export a V3AsymmetricSecretKey to hex for storage
func (V3AsymmetricSecretKey) Public ¶ added in v1.1.0
func (k V3AsymmetricSecretKey) Public() V3AsymmetricPublicKey
Public returns the corresponding public key for a secret key
type V3SymmetricKey ¶
type V3SymmetricKey struct {
// contains filtered or unexported fields
}
V3SymmetricKey v3 local symmetric key
func NewV3SymmetricKey ¶
func NewV3SymmetricKey() V3SymmetricKey
NewV3SymmetricKey generates a new symmetric key for encryption
func V3SymmetricKeyFromBytes ¶ added in v1.1.1
func V3SymmetricKeyFromBytes(bytes []byte) (V3SymmetricKey, error)
V3SymmetricKeyFromBytes constructs a key from bytes
func V3SymmetricKeyFromHex ¶
func V3SymmetricKeyFromHex(hexEncoded string) (V3SymmetricKey, error)
V3SymmetricKeyFromHex constructs a key from hex
func (V3SymmetricKey) ExportBytes ¶ added in v1.1.1
func (k V3SymmetricKey) ExportBytes() []byte
ExportBytes exports the key as raw byte array
func (V3SymmetricKey) ExportHex ¶
func (k V3SymmetricKey) ExportHex() string
ExportHex exports the key as hex for storage
type V4AsymmetricPublicKey ¶
type V4AsymmetricPublicKey struct {
// contains filtered or unexported fields
}
V4AsymmetricPublicKey v4 public public key
func NewV4AsymmetricPublicKeyFromBytes ¶ added in v1.1.1
func NewV4AsymmetricPublicKeyFromBytes(publicKey []byte) (V4AsymmetricPublicKey, error)
NewV4AsymmetricPublicKeyFromBytes Construct a v4 public key from bytes
func NewV4AsymmetricPublicKeyFromEd25519 ¶ added in v1.5.0
func NewV4AsymmetricPublicKeyFromEd25519(publicKey ed25519.PublicKey) (V4AsymmetricPublicKey, error)
NewV4AsymmetricPublicKeyFromEd25519 Construct a v2 public key from a standard Go object
func NewV4AsymmetricPublicKeyFromHex ¶
func NewV4AsymmetricPublicKeyFromHex(hexEncoded string) (V4AsymmetricPublicKey, error)
NewV4AsymmetricPublicKeyFromHex Construct a v4 public key from hex
func (V4AsymmetricPublicKey) ExportBytes ¶ added in v1.1.1
func (k V4AsymmetricPublicKey) ExportBytes() []byte
ExportBytes export a V4AsymmetricPublicKey to raw byte array
func (V4AsymmetricPublicKey) ExportHex ¶
func (k V4AsymmetricPublicKey) ExportHex() string
ExportHex export a V4AsymmetricPublicKey to hex for storage
type V4AsymmetricSecretKey ¶
type V4AsymmetricSecretKey struct {
// contains filtered or unexported fields
}
V4AsymmetricSecretKey v4 public private key
func NewV4AsymmetricSecretKey ¶
func NewV4AsymmetricSecretKey() V4AsymmetricSecretKey
NewV4AsymmetricSecretKey generate a new secret key for use with asymmetric cryptography. Don't forget to export the public key for sharing, DO NOT share this secret key.
func NewV4AsymmetricSecretKeyFromBytes ¶ added in v1.1.1
func NewV4AsymmetricSecretKeyFromBytes(privateKey []byte) (V4AsymmetricSecretKey, error)
NewV4AsymmetricSecretKeyFromBytes creates a secret key from bytes
func NewV4AsymmetricSecretKeyFromEd25519 ¶ added in v1.5.0
func NewV4AsymmetricSecretKeyFromEd25519(privateKey ed25519.PrivateKey) (V4AsymmetricSecretKey, error)
NewV4AsymmetricSecretKeyFromEd25519 creates a secret key from a standard Go object
func NewV4AsymmetricSecretKeyFromHex ¶
func NewV4AsymmetricSecretKeyFromHex(hexEncoded string) (V4AsymmetricSecretKey, error)
NewV4AsymmetricSecretKeyFromHex creates a secret key from hex
func NewV4AsymmetricSecretKeyFromSeed ¶
func NewV4AsymmetricSecretKeyFromSeed(hexEncoded string) (V4AsymmetricSecretKey, error)
NewV4AsymmetricSecretKeyFromSeed creates a secret key from a seed (hex)
func (V4AsymmetricSecretKey) ExportBytes ¶ added in v1.1.1
func (k V4AsymmetricSecretKey) ExportBytes() []byte
ExportBytes export a V4AsymmetricSecretKey to raw byte array
func (V4AsymmetricSecretKey) ExportHex ¶
func (k V4AsymmetricSecretKey) ExportHex() string
ExportHex export a V4AsymmetricSecretKey to hex for storage
func (V4AsymmetricSecretKey) ExportSeedHex ¶
func (k V4AsymmetricSecretKey) ExportSeedHex() string
ExportSeedHex export a V4AsymmetricSecretKey's seed to hex for storage
func (V4AsymmetricSecretKey) Public ¶
func (k V4AsymmetricSecretKey) Public() V4AsymmetricPublicKey
Public returns the corresponding public key for a secret key
type V4SymmetricKey ¶
type V4SymmetricKey struct {
// contains filtered or unexported fields
}
V4SymmetricKey v4 local symmetric key
func NewV4SymmetricKey ¶
func NewV4SymmetricKey() V4SymmetricKey
NewV4SymmetricKey generates a new symmetric key for encryption
func V4SymmetricKeyFromBytes ¶ added in v1.1.1
func V4SymmetricKeyFromBytes(bytes []byte) (V4SymmetricKey, error)
V4SymmetricKeyFromBytes constructs a key from bytes
func V4SymmetricKeyFromHex ¶
func V4SymmetricKeyFromHex(hexEncoded string) (V4SymmetricKey, error)
V4SymmetricKeyFromHex constructs a key from hex
func (V4SymmetricKey) ExportBytes ¶ added in v1.1.1
func (k V4SymmetricKey) ExportBytes() []byte
ExportBytes exports the key as raw byte array
func (V4SymmetricKey) ExportHex ¶
func (k V4SymmetricKey) ExportHex() string
ExportHex exports the key as hex for storage