Skip to content

Commit

Permalink
Renamed AttributeValues to ClaimAttributeValues
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemkaaas committed Jul 7, 2017
1 parent 0fe1be5 commit 0717414
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions anoncreds/protocol/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
NonRevocationClaimIssuer
from anoncreds.protocol.types import PrimaryClaim, NonRevocationClaim, \
Schema, ID, Claims, ClaimRequest, Attribs, PublicKey, \
RevocationPublicKey, AccumulatorPublicKey, AttributeValues
RevocationPublicKey, AccumulatorPublicKey, ClaimAttributeValues
from anoncreds.protocol.utils import strToInt, get_hash_as_int
from anoncreds.protocol.wallet.issuer_wallet import IssuerWallet
from config.config import cmod
Expand Down Expand Up @@ -97,7 +97,7 @@ async def revoke(self, schemaId: ID, i):

async def issueClaim(self, schemaId: ID, claimRequest: ClaimRequest,
iA=None,
i=None) -> (Claims, Dict[str, AttributeValues]):
i=None) -> (Claims, Dict[str, ClaimAttributeValues]):
"""
Issue a claim for the given user and schema.
Expand Down Expand Up @@ -159,7 +159,7 @@ async def _genContxt(self, schemaId: ID, iA, userId):
return m2

async def _issuePrimaryClaim(self, schemaId: ID, attributes: Attribs,
U) -> (PrimaryClaim, Dict[str, AttributeValues]):
U) -> (PrimaryClaim, Dict[str, ClaimAttributeValues]):
return await self._primaryIssuer.issuePrimaryClaim(schemaId,
attributes, U)

Expand Down
6 changes: 3 additions & 3 deletions anoncreds/protocol/primary/primary_claim_issuer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from anoncreds.protocol.globals import LARGE_VPRIME_PRIME, LARGE_E_START, \
LARGE_E_END_RANGE, LARGE_PRIME
from anoncreds.protocol.types import PublicKey, SecretKey, PrimaryClaim, ID, \
Attribs, AttributeValues
Attribs, ClaimAttributeValues
from anoncreds.protocol.utils import get_prime_in_range, strToCryptoInteger, \
randomQR
from anoncreds.protocol.wallet.issuer_wallet import IssuerWallet
Expand Down Expand Up @@ -74,7 +74,7 @@ def _genPrime(cls):
return prime

async def issuePrimaryClaim(self, schemaId: ID, attributes: Attribs,
U) -> (PrimaryClaim, Dict[str, AttributeValues]):
U) -> (PrimaryClaim, Dict[str, ClaimAttributeValues]):
u = strToCryptoInteger(U) if isinstance(U, str) else U

if not u:
Expand All @@ -92,7 +92,7 @@ async def issuePrimaryClaim(self, schemaId: ID, attributes: Attribs,

m2 = await self._wallet.getContextAttr(schemaId)
claimAttributes = \
{attr: AttributeValues(attributes._vals[attr], encodedAttrs[attr]) for attr in attributes.keys()}
{attr: ClaimAttributeValues(attributes._vals[attr], encodedAttrs[attr]) for attr in attributes.keys()}

return (PrimaryClaim(m2, A, e, vprimeprime), claimAttributes)

Expand Down
8 changes: 4 additions & 4 deletions anoncreds/protocol/primary/primary_proof_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from anoncreds.protocol.types import PrimaryClaim, Predicate, PrimaryInitProof, \
PrimaryEqualInitProof, PrimaryPrecicateGEInitProof, PrimaryProof, \
PrimaryEqualProof, PrimaryPredicateGEProof, \
ID, ClaimInitDataType, AttributeValues
ID, ClaimInitDataType, ClaimAttributeValues
from anoncreds.protocol.utils import splitRevealedAttrs, fourSquares
from anoncreds.protocol.wallet.prover_wallet import ProverWallet
from config.config import cmod
Expand Down Expand Up @@ -43,7 +43,7 @@ def __init__(self, wallet: ProverWallet):
async def initProof(self, schemaId, c1: PrimaryClaim,
revealedAttrs: Sequence[str],
predicates: Sequence[Predicate],
m1Tilde, m2Tilde, claimAttributes: Dict[str, AttributeValues]) -> PrimaryInitProof:
m1Tilde, m2Tilde, claimAttributes: Dict[str, ClaimAttributeValues]) -> PrimaryInitProof:
if not c1:
return None

Expand Down Expand Up @@ -72,7 +72,7 @@ async def finalizeProof(self, schemaId, cH,
return PrimaryProof(eqProof, geProofs)

async def _initEqProof(self, schemaId, c1: PrimaryClaim,
revealedAttrs: Sequence[str], m1Tilde, m2Tilde, claimAttributes: Dict[str, AttributeValues]) \
revealedAttrs: Sequence[str], m1Tilde, m2Tilde, claimAttributes: Dict[str, ClaimAttributeValues]) \
-> PrimaryEqualInitProof:
m2Tilde = m2Tilde if m2Tilde else cmod.integer(
cmod.randomBits(LARGE_MVECT))
Expand Down Expand Up @@ -106,7 +106,7 @@ async def _initEqProof(self, schemaId, c1: PrimaryClaim,
unrevealedAttrs.keys(), revealedAttrs)

async def _initGeProof(self, schemaId, eqProof: PrimaryEqualInitProof,
c1: PrimaryClaim, predicate: Predicate, claimAttributes: Dict[str, AttributeValues]) \
c1: PrimaryClaim, predicate: Predicate, claimAttributes: Dict[str, ClaimAttributeValues]) \
-> PrimaryPrecicateGEInitProof:
# gen U for Delta
pk = await self._wallet.getPublicKey(ID(schemaId=schemaId))
Expand Down
4 changes: 2 additions & 2 deletions anoncreds/protocol/prover.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from anoncreds.protocol.types import PrimaryClaim, NonRevocationClaim, Proof, \
InitProof, ProofInput, ProofClaims, \
FullProof, \
Schema, ID, SchemaKey, ClaimRequest, Claims, RequestedProof, AggregatedProof, ProofInfo, AttributeValues
Schema, ID, SchemaKey, ClaimRequest, Claims, RequestedProof, AggregatedProof, ProofInfo, ClaimAttributeValues
from anoncreds.protocol.utils import get_hash_as_int, isCryptoInteger
from anoncreds.protocol.wallet.prover_wallet import ProverWallet
from config.config import cmod
Expand Down Expand Up @@ -72,7 +72,7 @@ async def createClaimRequests(self, schemaIds: Sequence[ID],
reqNonRevoc)
return res

async def processClaim(self, schemaId: ID, claimAttributes: Dict[str, AttributeValues], signature: Claims):
async def processClaim(self, schemaId: ID, claimAttributes: Dict[str, ClaimAttributeValues], signature: Claims):
"""
Processes and saves a received Claim for the given Schema.
Expand Down
6 changes: 3 additions & 3 deletions anoncreds/protocol/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,10 +833,10 @@ def from_str_dict(cls, d):
self_attested_attrs=self_attested_attrs, predicates=predicates)


class AttributeValues(namedtuple('AttributeValues', 'raw, encoded'),
class ClaimAttributeValues(namedtuple('ClaimAttributeValues', 'raw, encoded'),
NamedTupleStrSerializer):
def __new__(cls, raw=None, encoded=None):
return super(AttributeValues, cls).__new__(cls, raw, encoded)
return super(ClaimAttributeValues, cls).__new__(cls, raw, encoded)

def to_str_dict(self):
return [self.raw, str(self.encoded)]
Expand All @@ -845,4 +845,4 @@ def to_str_dict(self):
def from_str_dict(cls, d):
raw = d[0]
encoded = int(to_crypto_int(d[1]))
return AttributeValues(raw=raw, encoded=encoded)
return ClaimAttributeValues(raw=raw, encoded=encoded)
6 changes: 3 additions & 3 deletions anoncreds/protocol/wallet/prover_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from anoncreds.protocol.repo.public_repo import PublicRepo
from anoncreds.protocol.types import ID, \
Claims, ClaimInitDataType, \
PrimaryClaim, NonRevocationClaim, ClaimsPair, AttributeValues
PrimaryClaim, NonRevocationClaim, ClaimsPair, ClaimAttributeValues
from anoncreds.protocol.wallet.wallet import Wallet, WalletInMemory
from typing import Dict, Sequence, Any

Expand All @@ -15,7 +15,7 @@ def __init__(self, schemaId, repo: PublicRepo):
# SUBMIT

@abstractmethod
async def submitClaimAttributes(self, schemaId: ID, claims: Dict[str, AttributeValues]):
async def submitClaimAttributes(self, schemaId: ID, claims: Dict[str, ClaimAttributeValues]):
raise NotImplementedError

@abstractmethod
Expand Down Expand Up @@ -100,7 +100,7 @@ def __init__(self, schemaId, repo: PublicRepo):

# SUBMIT

async def submitClaimAttributes(self, schemaId: ID, claims: Dict[str, AttributeValues]):
async def submitClaimAttributes(self, schemaId: ID, claims: Dict[str, ClaimAttributeValues]):
await self._cacheValueForId(self._claims, schemaId, claims)

async def submitPrimaryClaim(self, schemaId: ID, claim: PrimaryClaim):
Expand Down
8 changes: 4 additions & 4 deletions anoncreds/test/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from anoncreds.protocol.types import PublicKey, Schema, Claims, \
ProofInput, PredicateGE, FullProof, \
SchemaKey, ClaimRequest, Proof, AttributeInfo, ProofInfo, AggregatedProof, RequestedProof, PrimaryProof, \
PrimaryEqualProof, PrimaryPredicateGEProof, ID, AttributeValues
PrimaryEqualProof, PrimaryPredicateGEProof, ID, ClaimAttributeValues
from anoncreds.protocol.utils import toDictWithStrValues, fromDictWithStrValues
from config.config import cmod

Expand Down Expand Up @@ -194,13 +194,13 @@ async def test_requested_proof_from_to_dict(prover1, nonce, claimsProver1Gvt):
@pytest.mark.skipif('sys.platform == "win32"', reason='SOV-86')
@pytest.mark.asyncio
async def test_attribute_values_from_to_dict():
attr_values = AttributeValues(raw='Alex', encoded=cmod.integer(11))
attr_values = ClaimAttributeValues(raw='Alex', encoded=cmod.integer(11))

attr_values_serialized = ['Alex', '11']

assert attr_values.to_str_dict() == attr_values_serialized
assert attr_values == AttributeValues.from_str_dict(attr_values_serialized)
assert attr_values == AttributeValues.from_str_dict(attr_values.to_str_dict())
assert attr_values == ClaimAttributeValues.from_str_dict(attr_values_serialized)
assert attr_values == ClaimAttributeValues.from_str_dict(attr_values.to_str_dict())


@pytest.mark.skipif('sys.platform == "win32"', reason='SOV-86')
Expand Down

0 comments on commit 0717414

Please sign in to comment.