Making it easier to get an hrac from outside PolicyGroup.

pull/145/head
jMyles 2017-12-13 10:31:31 -08:00
parent 6554df9c03
commit 38e692a526
1 changed files with 9 additions and 1 deletions

View File

@ -110,6 +110,14 @@ class PolicyGroup(object):
pass # Tell Alice to either wait or lower the value of n.
def hrac(self):
"""
A convenience method for generating an hrac for this instance.
"""
return self.hrac_for(self.alice, self.bob, self.uri)
@staticmethod
def hrac_for(alice, bob, uri):
"""
The "hashed resource authentication code".
@ -121,7 +129,7 @@ class PolicyGroup(object):
Alice and Bob have all the information they need to construct this.
Ursula does not, so we share it with her.
"""
return self.hash(bytes(self.alice.seal) + bytes(self.bob.seal) + self.uri)
return PolicyGroup.hash(bytes(alice.seal) + bytes(bob.seal) + uri)
def treasure_map_dht_key(self):
"""