class IcAgent::DelegateIdentity

Attributes

delegations[R]
der_pubkey[R]
identity[R]

Public Class Methods

from_json(ic_identity, ic_delegation) click to toggle source

Creates a new DelegateIdentity instance from JSON representations of the Identity and delegation.

Parameters:

  • ic_identity: The JSON representation of the Identity.

  • ic_delegation: The JSON representation of the delegation.

Returns: The DelegateIdentity instance.

# File lib/ic_agent/identity.rb, line 161
def self.from_json(ic_identity, ic_delegation)
  parsed_ic_identity = JSON.parse(ic_identity)
  parsed_ic_delegation = JSON.parse(ic_delegation)

  DelegateIdentity.new(
    Identity.new(parsed_ic_identity[1][0...64]),
    parsed_ic_delegation
  )
end
new(identity, delegation) click to toggle source

Initializes a new instance of the DelegateIdentity class.

Parameters:

  • identity: The Identity associated with the DelegateIdentity.

  • delegation: The delegation JSON object containing the delegated keys.

# File lib/ic_agent/identity.rb, line 131
def initialize(identity, delegation)
  @identity = identity
  @delegations = delegation['delegations'].map { |d| d }
  @der_pubkey = [delegation['publicKey']].pack('H*')
end

Public Instance Methods

inspect()
Alias for: to_s
sender() click to toggle source

Returns the sender Principal associated with the DelegateIdentity.

Returns: The sender Principal.

# File lib/ic_agent/identity.rb, line 150
def sender
  Principal.self_authenticating(@der_pubkey)
end
sign(msg) click to toggle source

Signs a message using the DelegateIdentity.

Parameters:

  • msg: The message to sign.

Returns: An array containing the DER-encoded public key and the signature.

# File lib/ic_agent/identity.rb, line 143
def sign(msg)
  @identity.sign(msg)
end
to_s() click to toggle source
# File lib/ic_agent/identity.rb, line 171
def to_s
  "(#{@identity.to_s},\n#{@delegations.to_s})"
end
Also aliased as: inspect