crypto

package
v0.0.0-...-2c2efe1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package crypto - wrapper for encryption libraries required by service

Index

Constants

View Source
const BFSBLS381 int = int(C.BFS_BLS381)

BFSBLS381 Field size

View Source
const BGSBLS381 int = int(C.BGS_BLS381)

BGSBLS381 Group size

View Source
const G2Len int = 4 * BFSBLS381

G2Len G2 point size

View Source
const SIGLen int = BFSBLS381 + 1

SIGLen Signature length

Variables

This section is empty.

Functions

func AESCBCDecrypt

func AESCBCDecrypt(k []byte, iv []byte, c []byte) (p []byte)

AESCBCDecrypt AES-CBC Decryption

AES decryption using CBC mode

@param K            Key
@param IV           Initialization vector IV (16 bytes)
@param C            Ciphertext
@param P            Plaintext

func AESCBCEncrypt

func AESCBCEncrypt(k []byte, iv []byte, p []byte) (c []byte)

AESCBCEncrypt AES-CBC Encryption

AES encryption using CBC mode

@param K            Key
@param IV           Initialization vector IV (16 bytes)
@param P            Plaintext
@param C            Ciphertext

func BLSAddG1

func BLSAddG1(R1 []byte, R2 []byte) (rc int, R []byte)

BLSAddG1 Add two members from the group G1

Add two members from the group G1

@param R1           member of G1
@param R2           member of G1
@param R            member of G1. r = r1+r2
@param rc           Return code. Zero for success or else an error code

func BLSAddG2

func BLSAddG2(R1 []byte, R2 []byte) (rc int, R []byte)

BLSAddG2 Add two members from the group G2

Add two members from the group G2

@param R1           member of G2
@param R2           member of G2
@param R            member of G2. r = r1+r2
@param rc           Return code. Zero for success or else an error code

func BLSKeys

func BLSKeys(seed []byte, ski []byte) (rc int, pk []byte, sko []byte)

BLSKeys Generate BLS keys

Generate public and private key pair. If the seed value is nil then generate the public key using the input secret key.

@param seed seed value for CSPRNG. @param ski input secret key @param pk public key @param sko output secret key @param rc Return code. Zero for success or else an error code

func BLSMakeShares

func BLSMakeShares(k int, n int, seed []byte, ski []byte) (rc int, x []byte, y []byte, sko []byte)

BLSMakeShares Use Shamir's secret sharing to distribute BLS secret keys

Use Shamir's secret sharing to distribute BLS secret keys

@param k Threshold @param n Number of shares @param seed seed value for CSPRNG @param ski Secret key to be shared. @param x x values @param y y values. Valid BLS secret keys @param rc Zero for success or else an error code

func BLSRecoverSecret

func BLSRecoverSecret(k int, x []byte, y []byte) (rc int, sk []byte)

BLSRecoverSecret Use Shamir's secret sharing to recover a BLS secret key

Use Shamir's secret sharing to recover a BLS secret key

@param k Threshold @param x x values @param y y values. Valid BLS secret keys @param sk Secret key that is recovered @param rc Zero for success or else an error code

func BLSRecoverSignature

func BLSRecoverSignature(k int, x []byte, y []byte) (rc int, sig []byte)

BLSRecoverSignature Use Shamir's secret sharing to recover a BLS signature

Use Shamir's secret sharing to recover a BLS signature

@param k Threshold @param x x values @param y y values. Valid BLS signatures @param sig Signature that is recovered @param rc Zero for success or else an error code

func BLSSign

func BLSSign(m []byte, sk []byte) (rc int, s []byte)

BLSSign Sign a message

The message is signed using the BLS algorithm

@param M            Message to be signed
@param sk           secret key
@param S            Signature
@param rc           Return code. Zero for success or else an error code

func BLSVerify

func BLSVerify(m []byte, pk []byte, s []byte) (rc int)

BLSVerify Verify a signature

Verify a signature using the BLS algorithm

@param M            Message that was signed
@param pk           public key
@param S            Signature
@param rc           Return code. Zero for success or else an error code

func DecapsulateDecrypt

func DecapsulateDecrypt(c []byte, iv []byte, sikeSK []byte, ek []byte) (rc int, p []byte)

DecapsulateDecrypt Decapsulate the AES Key and decrypt the message

Decapsulate the AES key and use it to decrypt the ciphertext. The plaintext is returned using the C parameter.

@param C Ciphertext to be decrypted @param IV Initialization vector IV @param sikeSK SIKE secret key @param EK Encapsulated key @param P Plaintext @param rc Return code. Zero for success or else an error code

func EncapsulateEncrypt

func EncapsulateEncrypt(p []byte, iv []byte, sikePK []byte) (rc int, c []byte, ek []byte)

EncapsulateEncrypt Encrypt a message and encapsulate the AES Key for a recipient.

The  message is encrypted using AES-256. The key
is generated inside this function as an output
from the encapsulation function. The ciphertext
is returned using the P paramter.

@param P            Plaintext to be encrypted
@param IV           Initialization vector IV (16 bytes)
@param sikePK       SIKE public key
@param C            Ciphertext
@param EK           Encapsulated key
@param rc           Return code. Zero for success or else an error code

func SIKEKeys

func SIKEKeys(seed []byte) (rc int, sikePK []byte, sikeSK []byte)

SIKEKeys Generate SIKE keys

Generate SIKE public and private key pair

@param seed seed value for CSPRNG @param sikePK SIKE public key @param sikeSK SIKE secret key @param rc Return code. Zero for success or else an error code

func Secp256k1Decrypt

func Secp256k1Decrypt(C, V, T, sK string) (message string, err error)

Secp256k1Decrypt decrypts an encrypoted message using ECP_SECP256K1_ECIES

func Secp256k1Encrypt

func Secp256k1Encrypt(message, publicKey string) (C, V, T string, err error)

Secp256k1Encrypt encrypts a message using ECP_SECP256K1_ECIES

Types

type Octet

type Octet = C.octet

Octet adds functionality around C octet

func CreateOctet

func CreateOctet(val []byte) *Octet

CreateOctet creates new Octet with a value

func NewOctet

func NewOctet(maxSize int) *Octet

NewOctet creates an empty Octet with a given size

func (*Octet) Free

func (o *Octet) Free()

Free frees the allocated memory

func (*Octet) ToBytes

func (o *Octet) ToBytes() []byte

ToBytes returns the bytes representation of the Octet

func (*Octet) ToString

func (o *Octet) ToString() string

ToString returns the hex encoded representation of the Octet

type Rand

type Rand C.csprng

Rand is a cryptographically secure random number generator

func NewRand

func NewRand(seed []byte) *Rand

NewRand create new seeded Rand

Jump to

Keyboard shortcuts

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