crypto

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewECPointReader

func NewECPointReader(r io.Reader) *pointReader

NewECPointReader returns an elliptic curve point reader

func NewECPointWriter

func NewECPointWriter(w io.Writer) *pointWriter

NewECPointWriter returns an elliptic curve point writer

func PseudorandomCode

func PseudorandomCode(aesBlock cipher.Block, src []byte, hIdx byte) []byte

PseudorandomCode is implemented as follows: C(x) = AES(1||h(x)[:15]) ||

AES(2||h(x)[:15]) ||
AES(3||h(x)[:15]) ||
AES(4||h(x)[:15])

where h() is the Murmur3 hashing function. PseudorandomCode is passed the src as well as the associated hash index. It also requires an AES block cipher. The full pseudorandom code consists of four 16 byte encrypted AES blocks that are encoded into a slice of 64 bytes. The hash function is constructed with the hash index as its two seeds. It is fed the full ID source. It returns two uint64s which are cast to a slice of bytes. The output is shifted right to allow prepending of the block index. For each block, the prepended value is changed to indicate the block index (1, 2, 3, 4) before being used as the source for the AES encode.

func PseudorandomGenerate

func PseudorandomGenerate(dst []byte, seed []byte, h *blake3.Hasher) error

PseudorandomGenerate is a pseudorandom generator (PRG) using a deterministic random bit generator (DRBG) as specified by NIST - Special Publication 800-90A Revision 1. Blake3 is not normally used as a DRBG but we've applied it here for performance reasons.

func XorCipherWithBlake3

func XorCipherWithBlake3(key []byte, ind byte, src []byte) []byte

XorCipherWithBlake3 uses the output of Blake3 XOF as pseudorandom bytes to perform a XOR cipher.

Types

type Point

type Point struct {
	// contains filtered or unexported fields
}

Point represents a point on the P256 elliptic curve

func GenerateKey

func GenerateKey() ([]byte, *Point, error)

GenerateKey returns a secret and public key pair

func NewPoint

func NewPoint() *Point

NewPoint returns a Point

func (*Point) Add

func (p *Point) Add(q *Point) *Point

Add adds two points

func (*Point) DeriveKeyFromECPoint

func (p *Point) DeriveKeyFromECPoint() []byte

DeriveKeyFromECPoint returns a key of 32 byte

func (*Point) Marshal

func (p *Point) Marshal() []byte

Marshal converts a Point to a byte slice representation

func (*Point) ScalarMult

func (p *Point) ScalarMult(scalar []byte) *Point

ScalarMult multiplies a point with a scalar

func (*Point) Sub

func (p *Point) Sub(q *Point) *Point

Sub substracts point p from q

func (*Point) Unmarshal

func (p *Point) Unmarshal(marshaledPoint []byte) error

Unmarshal takes in a marshaledPoint byte slice and extracts the Point object

Jump to

Keyboard shortcuts

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