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)
| 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 |
| 29 | func 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 |
no test coverage detected