Class: ORE::AES128::Ciphertext

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/ore/aes128/ciphertext.rb

Overview

An ORE ciphertext produced by an AES128 cipher.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(ct, n) ⇒ Object

Create a ciphertext object from a serialized form.

ORE ciphertexts can be serialized (using #to_s), and then deserialized by passing them into this constructor.

Parameters:

  • ct (String)

    the serialized ciphertext. This must be a ‘BINARY` encoded string.

  • n (Integer)

    the number of ORE blocks contained in the ciphertext. Each ORE block represents one octet of the plaintext. At present, only 64-bit plaintexts are supported, so this must always be ‘8`.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ore/aes128/ciphertext.rb', line 22

def self.new(ct, n)
  unless ct.is_a?(String)
    raise ArgumentError, "Ciphertext must be a string"
  end

  unless n == 8
    raise ArgumentError, "Only a block count of 8 is currently supported"
  end

  _new(ct, n)
end

Instance Method Details

#<=>(other) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/ore/aes128/ciphertext.rb', line 38

def <=>(other)
  unless other.is_a?(ORE::AES128::Ciphertext)
    raise ArgumentError, "Cannot compare an ORE ciphertext to anything other than another ciphertext"
  end

  _cmp(other)
end

#to_sObject



34
35
36
# File 'lib/ore/aes128/ciphertext.rb', line 34

def to_s
  _serialize
end