gitlab.com/SiaPrime/SiaPrime@v1.4.1/crypto/plaintext.go (about) 1 package crypto 2 3 type ( 4 // plainTextCipherKey implements the SiaCipherKey interface but doesn't 5 // encrypt or decrypt data. 6 plainTextCipherKey struct{} 7 ) 8 9 // Type returns the type of the plaintext 'key'. 10 func (plainTextCipherKey) Type() CipherType { 11 return TypePlain 12 } 13 14 // Cipherkey returns the plaintext key which is an empty slice. 15 func (plainTextCipherKey) Key() []byte { 16 return []byte{} 17 } 18 19 // DecryptBytes is a no-op for the plainTextCipherKey. 20 func (plainTextCipherKey) DecryptBytes(ct Ciphertext) ([]byte, error) { 21 return ct[:], nil 22 } 23 24 // DecryptBytesInPlace is a no-op for the plainTextCipherKey. 25 func (plainTextCipherKey) DecryptBytesInPlace(ct Ciphertext, _ uint64) ([]byte, error) { 26 return ct[:], nil 27 } 28 29 // Derive for a plainTextCipherKey simply returns itself since there is no key 30 // to derive from. 31 func (p plainTextCipherKey) Derive(_, _ uint64) CipherKey { 32 return p 33 } 34 35 // EncryptBytes is a no-op for the plainTextCipherKey. 36 func (plainTextCipherKey) EncryptBytes(piece []byte) Ciphertext { 37 return Ciphertext(piece) 38 }