timelockencoders

package
v0.0.0-...-7ad0b1f Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAESRSWPuzzleWithPrimes

func CreateAESRSWPuzzleWithPrimes(a uint64, t uint64, message []byte, p *big.Int, q *big.Int) (ciphertext []byte, puzzle rsw.PuzzleRSW, err error)

CreateAESRSWPuzzleWithPrimes creates a RSW timelock puzzle with time t and encrypts the message using AES, given some user-defined primes. This returns a struct unlike the other methods here.

func CreatePuzzleAES

func CreatePuzzleAES(t uint64, message []byte, puzzleCreator func(uint64, []byte) (crypto.Puzzle, []byte, error)) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreatePuzzleAES creates a RSW timelock puzzle with time t and encrypts the message using AES.

func CreatePuzzleRC5

func CreatePuzzleRC5(t uint64, message []byte, puzzleCreator func(uint64, []byte) (crypto.Puzzle, []byte, error)) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreatePuzzleRC5 creates a timelock puzzle with time t and encrypts the message using RC5.

func CreatePuzzleRC6

func CreatePuzzleRC6(t uint64, message []byte, puzzleCreator func(uint64, []byte) (crypto.Puzzle, []byte, error)) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreatePuzzleRC6 creates a timelock puzzle with time t and encrypts the message using RC6.

func CreateRC5RSWPuzzleWithPrimes

func CreateRC5RSWPuzzleWithPrimes(a uint64, t uint64, message []byte, p *big.Int, q *big.Int) (ciphertext []byte, puzzle rsw.PuzzleRSW, err error)

CreateRC5RSWPuzzleWithPrimes creates a RSW timelock puzzle with time t and encrypts the message using RC5, given some user-defined primes. This returns a struct unlike the other methods here.

func CreateRSW2048A2PuzzleAES

func CreateRSW2048A2PuzzleAES(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreateRSW2048A2PuzzleAES creates a RSW timelock puzzle with time t and encrypts the message using AES.

func CreateRSW2048A2PuzzleECIES

func CreateRSW2048A2PuzzleECIES(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreateRSW2048A2PuzzleECIES creates a RSW timelock puzzle with time t and encrypts the message using ECIES. We're using seckp256k1. Here's our process because working with ethereum types is annoying and people seem to not like marshalling private keys Generate s256 ethcrypto ecdsa key -> use FromECDSA to create bytes with ethcrypto lib, convert to ecies privkey and encrypt message -> send that in puzzle -> once puzzle is solved, unmarshal to ecies privkey, use to decrypt

func CreateRSW2048A2PuzzleRC5

func CreateRSW2048A2PuzzleRC5(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreateRSW2048A2PuzzleRC5 creates a RSW timelock puzzle with time t and encrypts the message using RC5. This is consistent with the scheme described in RSW96.

func CreateRSW2048A2PuzzleRC6

func CreateRSW2048A2PuzzleRC6(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreateRSW2048A2PuzzleRC6 creates a RSW timelock puzzle with time t and encrypts the message using RC6.

func CreateRSW2048A2PuzzleRSA

func CreateRSW2048A2PuzzleRSA(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreateRSW2048A2PuzzleRSA creates a RSW timelock puzzle with time t and encrypts the message using RSA. We marshal the key to PKCS1

func CreateSHAPuzzleAES

func CreateSHAPuzzleAES(t uint64, message []byte) (ciphertext []byte, puzzle crypto.Puzzle, err error)

CreateSHAPuzzleAES creates a hash timelock puzzle with time t and encrypts the message using AES.

func DecryptPuzzleAES

func DecryptPuzzleAES(ciphertext []byte, key []byte) (message []byte, err error)

DecryptPuzzleAES decrypts the ciphertext using AES

func DecryptPuzzleRC5

func DecryptPuzzleRC5(ciphertext []byte, key []byte) (message []byte, err error)

DecryptPuzzleRC5 decrypts the ciphertext using RC5

func Generate16ByteKey

func Generate16ByteKey(rand io.Reader) (key []byte, err error)

Generate16ByteKey generates a 16 byte long key to be used for AES, RC5, or RC6 from a reader

func GenerateIV

func GenerateIV(rand io.Reader, blockCipher cipher.Block) (iv []byte, err error)

GenerateIV generates an initialization vector with the block size of the cipher

func SolvePuzzleAES

func SolvePuzzleAES(ciphertext []byte, puzzle crypto.Puzzle) (message []byte, err error)

SolvePuzzleAES solves the timelock puzzle and decrypts the ciphertext using AES

func SolvePuzzleECIES

func SolvePuzzleECIES(ciphertext []byte, puzzle crypto.Puzzle) (message []byte, err error)

SolvePuzzleECIES solves the timelock puzzle and decrypts the ciphertext using ECIES. We assume the key is an ASN.1 ECPKS

func SolvePuzzleRC5

func SolvePuzzleRC5(ciphertext []byte, puzzle crypto.Puzzle) (message []byte, err error)

SolvePuzzleRC5 solves the timelock puzzle and decrypts the ciphertext using RC5

func SolvePuzzleRC6

func SolvePuzzleRC6(ciphertext []byte, puzzle crypto.Puzzle) (message []byte, err error)

SolvePuzzleRC6 solves the timelock puzzle and decrypts the ciphertext using RC6

func SolvePuzzleRSA

func SolvePuzzleRSA(ciphertext []byte, puzzle crypto.Puzzle) (message []byte, err error)

SolvePuzzleRSA solves the timelock puzzle and decrypts the ciphertext using RSA. We assume the key is in PKCS1 format

Types

This section is empty.

Jump to

Keyboard shortcuts

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