MCPcopy Create free account
hub / github.com/deroproject/derohe / EncryptDecryptUserData

Function EncryptDecryptUserData

cryptography/crypto/userdata.go:29–41  ·  view source on GitHub ↗

default discard all logs, someone needs to set this up this function is used to encrypt/decrypt payment id,srcid and other userdata as the operation is symmetric XOR, is the same in both direction

(key [32]byte, inputs ...[]byte)

Source from the content-addressed store, hash-verified

27// this function is used to encrypt/decrypt payment id,srcid and other userdata
28// as the operation is symmetric XOR, is the same in both direction
29func EncryptDecryptUserData(key [32]byte, inputs ...[]byte) {
30 var nonce [24]byte // nonce is 24 bytes, we will use xchacha20
31
32 cipher, err := chacha20.NewUnauthenticatedCipher(key[:], nonce[:])
33 if err != nil {
34 panic(err)
35 }
36
37 for _, input := range inputs {
38 cipher.XORKeyStream(input, input)
39 }
40 return
41}
42
43// does an ECDH and generates a shared secret
44// https://en.wikipedia.org/wiki/Elliptic_curve_Diffie%E2%80%93Hellman

Callers 3

ProveFunction · 0.92
BuildTransactionMethod · 0.92
synchistory_blockMethod · 0.92

Calls 1

XORKeyStreamMethod · 0.80

Tested by

no test coverage detected