Class: Fabric::Identity
- Inherits:
-
Object
- Object
- Fabric::Identity
- Defined in:
- lib/fabric/identity.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#certificate ⇒ Object
Returns the value of attribute certificate.
-
#crypto_suite ⇒ Object
readonly
Returns the value of attribute crypto_suite.
-
#mspid ⇒ Object
Returns the value of attribute mspid.
-
#private_key ⇒ Object
readonly
Returns the value of attribute private_key.
-
#public_key ⇒ Object
readonly
Returns the value of attribute public_key.
Instance Method Summary collapse
- #decoded_certificate ⇒ Object
- #generate_csr(attrs = []) ⇒ Object
-
#initialize(crypto_suite, opts = {}) ⇒ Identity
constructor
A new instance of Identity.
- #serialize ⇒ Object
- #shared_secret_by(public_key) ⇒ Object
- #sign(message) ⇒ Object
Constructor Details
#initialize(crypto_suite, opts = {}) ⇒ Identity
Returns a new instance of Identity.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/fabric/identity.rb', line 12 def initialize(crypto_suite, opts = {}) @crypto_suite = crypto_suite @private_key = opts[:private_key] || @crypto_suite.generate_private_key @public_key = opts[:public_key] || @crypto_suite.restore_public_key(private_key) @certificate = opts[:certificate] @mspid = opts[:mspid] @address = @crypto_suite.address_from_public_key public_key end |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
5 6 7 |
# File 'lib/fabric/identity.rb', line 5 def address @address end |
#certificate ⇒ Object
Returns the value of attribute certificate.
10 11 12 |
# File 'lib/fabric/identity.rb', line 10 def certificate @certificate end |
#crypto_suite ⇒ Object (readonly)
Returns the value of attribute crypto_suite.
5 6 7 |
# File 'lib/fabric/identity.rb', line 5 def crypto_suite @crypto_suite end |
#mspid ⇒ Object
Returns the value of attribute mspid.
10 11 12 |
# File 'lib/fabric/identity.rb', line 10 def mspid @mspid end |
#private_key ⇒ Object (readonly)
Returns the value of attribute private_key.
5 6 7 |
# File 'lib/fabric/identity.rb', line 5 def private_key @private_key end |
#public_key ⇒ Object (readonly)
Returns the value of attribute public_key.
5 6 7 |
# File 'lib/fabric/identity.rb', line 5 def public_key @public_key end |
Instance Method Details
#decoded_certificate ⇒ Object
35 36 37 |
# File 'lib/fabric/identity.rb', line 35 def decoded_certificate Base64.strict_decode64 certificate end |
#generate_csr(attrs = []) ⇒ Object
23 24 25 |
# File 'lib/fabric/identity.rb', line 23 def generate_csr(attrs = []) @crypto_suite.generate_csr private_key, attrs end |
#serialize ⇒ Object
39 40 41 |
# File 'lib/fabric/identity.rb', line 39 def serialize Msp::SerializedIdentity.new(mspid: mspid, id_bytes: decoded_certificate).to_proto end |
#shared_secret_by(public_key) ⇒ Object
31 32 33 |
# File 'lib/fabric/identity.rb', line 31 def shared_secret_by(public_key) @crypto_suite.build_shared_key private_key, public_key end |
#sign(message) ⇒ Object
27 28 29 |
# File 'lib/fabric/identity.rb', line 27 def sign() @crypto_suite.sign(private_key, ) end |