Documentation ¶
Index ¶
- Constants
- Variables
- func ChameleonHash(parameters *ChameleonHashParameters, checkString *ChameleonHashCheckString, ...) [32]byte
- func CreateRSAKeyFile(filename string) error
- func CreateRSAPrivKeyFromBase64(strModulus string, strPrivExponent string, strPrimes []string) (privKey *rsa.PrivateKey, err error)
- func CreateRSAPubKeyFromBytes(bytModulus [COMM_KEY_LENGTH]byte) (pubKey *rsa.PublicKey, err error)
- func ExtractECDSAKeyFromFile(filename string) (privKey *ecdsa.PrivateKey, err error)
- func ExtractRSAKeyFromFile(filename string) (privKey *rsa.PrivateKey, err error)
- func GetAddressFromPubKey(pubKey *ecdsa.PublicKey) (address [64]byte)
- func GetOrCreateECDSAPublicKeyFromFile(filename string) (pubKey *ecdsa.PublicKey, err error)
- func GetPrivKeyFromString(x, y, d string) (privateKey *ecdsa.PrivateKey, err error)
- func GetPubKeyFromString(x, y string) (pubKey *ecdsa.PublicKey, err error)
- func ReadFile(filename string) (lines []string)
- func SignMessageWithRSAKey(privKey *rsa.PrivateKey, msg string) (fixedSig [COMM_PROOF_LENGTH]byte, err error)
- func VerifyECDSAKey(privKey *ecdsa.PrivateKey) error
- func VerifyMessageWithRSAKey(pubKey *rsa.PublicKey, msg string, fixedSig [COMM_PROOF_LENGTH]byte) (err error)
- func VerifyRSAKey(privKey *rsa.PrivateKey) error
- type ChameleonHashCheckString
- type ChameleonHashParameters
Constants ¶
const ( // Note that this is the default public exponent set by Golang in rsa.go // See https://github.com/golang/go/blob/6269dcdc24d74379d8a609ce886149811020b2cc/src/crypto/rsa/rsa.go#L226 COMM_PUBLIC_EXPONENT = 65537 COMM_KEY_BITS = 2048 COMM_PROOF_LENGTH = 256 COMM_KEY_LENGTH = 256 COMM_NOF_PRIMES = 2 )
const CH_PARAM_SIZE = 64
const CH_SIZE = 256 // Length of a single parameter in bytes.
const HEX_BASE = 16
Variables ¶
var (
ChameleonHashParametersMap = make(map[[32]byte]*ChameleonHashParameters)
)
Functions ¶
func ChameleonHash ¶
func ChameleonHash(parameters *ChameleonHashParameters, checkString *ChameleonHashCheckString, message *[]byte) [32]byte
Returns the chameleon hash form a set of chameleon hash parameters, a check string and a message to hash.
func CreateRSAKeyFile ¶
Creates an RSA key file with the following lines 1 Public Modulus N 2 Private Exponent D 3+ Private Primes (depending on COMM_NOF_PRIMES)
func CreateRSAPubKeyFromBytes ¶
func CreateRSAPubKeyFromBytes(bytModulus [COMM_KEY_LENGTH]byte) (pubKey *rsa.PublicKey, err error)
func ExtractECDSAKeyFromFile ¶
func ExtractECDSAKeyFromFile(filename string) (privKey *ecdsa.PrivateKey, err error)
func ExtractRSAKeyFromFile ¶
func ExtractRSAKeyFromFile(filename string) (privKey *rsa.PrivateKey, err error)
func GetAddressFromPubKey ¶
func GetPrivKeyFromString ¶
func GetPrivKeyFromString(x, y, d string) (privateKey *ecdsa.PrivateKey, err error)
func GetPubKeyFromString ¶
func SignMessageWithRSAKey ¶
func SignMessageWithRSAKey(privKey *rsa.PrivateKey, msg string) (fixedSig [COMM_PROOF_LENGTH]byte, err error)
func VerifyECDSAKey ¶
func VerifyECDSAKey(privKey *ecdsa.PrivateKey) error
func VerifyMessageWithRSAKey ¶
func VerifyRSAKey ¶
func VerifyRSAKey(privKey *rsa.PrivateKey) error
Types ¶
type ChameleonHashCheckString ¶
func GenerateChCollision ¶
func GenerateChCollision( parameters *ChameleonHashParameters, checkString *ChameleonHashCheckString, oldMessage *[]byte, newMessage *[]byte, ) *ChameleonHashCheckString
Generates a hash collision for two different inputs (oldMessage, newMessage) and returns a new check string. ===== USAGE ===== newCheckString := GenerateChamHashCollision(params, oldCheckString, oldMessage, newMessage) ChameleonHash(params, oldCheckString, oldMessage) == ChameleonHash(params, newCheckString, newMessage)
func NewCheckString ¶
func NewCheckString(parameters *ChameleonHashParameters) *ChameleonHashCheckString
Generates a new CheckString from the provided parameters.
type ChameleonHashParameters ¶
type ChameleonHashParameters struct { G []byte // Prime P []byte // Prime Q []byte // Prime HK []byte // Public Hash Key TK []byte // Secret Trapdoor Key. Never share this key with others. }
func GetOrCreateParametersFromFile ¶
func GetOrCreateParametersFromFile(filename string) (parameters *ChameleonHashParameters, err error)
Retrieve a set of chameleon hash parameters from file. Creates a new set of parameters if the file not exists.
func GetParametersFromString ¶
func GetParametersFromString(g, p, q, hk, tk string) (parameters *ChameleonHashParameters, err error)
Get chameleon hash parameters from a set of hex strings
func (ChameleonHashParameters) String ¶
func (parameters ChameleonHashParameters) String() string