Skip to content

Commit

Permalink
Merge pull request #159 from alastria/feature/newCredentialFunctions
Browse files Browse the repository at this point in the history
update credential examples in order to use new SCs functions
  • Loading branch information
DaniRumpi authored Nov 11, 2024
2 parents a9fe85a + be3aed2 commit 10bf4d3
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 23 deletions.
10 changes: 6 additions & 4 deletions configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,23 @@
"field_name": "email"
}
],
"entity1": "0x59e23b61f42877d14231f05996b9089a2f6081b5",
"didEntity1": "did:ala:quor:redT:59e23b61f42877d14231f05996b9089a2f6081b5",
"entity1": "0x4820ae942d23287c84e8c3b08d415c12e7617fb5",
"didEntity1": "did:ala:quor:redT:4820ae942d23287c84e8c3b08d415c12e7617fb5",
"entity2": "0x6d26cdd054ad1f7dd51cfe28e449c4cd33bc3165",
"didEntity2": "did:ala:quor:redT:6d26cdd054ad1f7dd51cfe28e449c4cd33bc3165",
"entity3": "0x4e9363e45f3b8b6f0ef8d7cdbf4df1d1a36e0089",
"didEntity3": "did:ala:quor:redT:4e9363e45f3b8b6f0ef8d7cdbf4df1d1a36e0089",
"subject1": "0x576a5823d80dc7974438c4eb6fc861921d525c3e",
"didSubject1": "did:ala:quor:redT:576a5823d80dc7974438c4eb6fc861921d525c3e",
"subject1": "0x501aacc575022971143af46a647dfbd40179582d",
"didSubject1": "did:ala:quor:redT:501aacc575022971143af46a647dfbd40179582d",
"subject2": "0x02976e59938f023e5a868e520401648df6ce8d9d",
"didSubject2": "did:ala:quor:redT:02976e59938f023e5a868e520401648df6ce8d9d",
"issuerLevel": 2,
"issuedCredentialStatus": 0,
"updateSubject1PresentationTo": 2,
"updateEntity2PresentationTo": 1,
"revokeEntity2Presentation": 3,
"updateIssuerCredentialTo": 2,
"updateSubjectCredentialTo": 3,
"subject1PresentationStatus": {
"exist": true,
"status": "2"
Expand Down
9 changes: 5 additions & 4 deletions exampleCredentials/1.addEntity1Credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ fs.writeFileSync(
JSON.stringify({ psmhash: credentialHash, jwt: signedJWTCredential })
)

function addIssuerCredential() {
function updateIssuerCredential() {
const issuerCredential =
transactionFactory.credentialRegistry.addIssuerCredential(
transactionFactory.credentialRegistry.updateIssuerCredential(
web3,
credentialHash
credentialHash,
configData.issuedCredentialStatus
)
console.log('(addIssuerCredential)The transaction is: ', issuerCredential)
return issuerCredential
Expand All @@ -123,7 +124,7 @@ function sendSigned(issuerCredentialSigned) {
}

async function main() {
const resultIssuerCredential = await addIssuerCredential()
const resultIssuerCredential = await updateIssuerCredential()

const issuerCredentialSigned = await entity1Identity.getKnownTransaction(
resultIssuerCredential
Expand Down
8 changes: 4 additions & 4 deletions exampleCredentials/3.addSubject1Credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ fs.writeFileSync(
JSON.stringify({ psmhash: subjectCredentialHash, jwt: signedJWTCredential })
)

function addSubjectCredential() {
function updateSubjectCredential() {
const subjectCredential =
transactionFactory.credentialRegistry.addSubjectCredential(
transactionFactory.credentialRegistry.updateSubjectCredential(
web3,
subjectCredentialHash,
uri
configData.issuedCredentialStatus
)
console.log('(addSubjectCredential)The transaction is: ', subjectCredential)
return subjectCredential
Expand All @@ -92,7 +92,7 @@ function sendSigned(subjectCredentialSigned) {
}

async function main() {
const resultSubjectCredential = await addSubjectCredential()
const resultSubjectCredential = await updateSubjectCredential()

const subjectCredentialSigned = await subject1Identity.getKnownTransaction(
resultSubjectCredential
Expand Down
2 changes: 1 addition & 1 deletion exampleCredentials/5.updateEntity1Credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const Web3 = require('web3')
const myBlockchainServiceIp = configData.nodeURL
const web3 = new Web3(new Web3.providers.HttpProvider(myBlockchainServiceIp))

const updateCredentialStatus = transactionFactory.credentialRegistry.updateCredentialStatus(
const updateCredentialStatus = transactionFactory.credentialRegistry.updateIssuerCredential(
web3,
credentialHash.psmhash,
configData.updateIssuerCredentialTo
Expand Down
5 changes: 3 additions & 2 deletions exampleCredentials/6.deleteSubject1Credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const myBlockchainServiceIp = configData.nodeURL
const web3 = new Web3(new Web3.providers.HttpProvider(myBlockchainServiceIp))

const deleteCredentialStatus =
transactionFactory.credentialRegistry.deleteSubjectCredential(
transactionFactory.credentialRegistry.updateSubjectCredential(
web3,
credentialHash.psmhash
credentialHash.psmhash,
configData.updateSubjectCredentialTo
)

const keyDataSubject1 = fs.readFileSync(
Expand Down
2 changes: 1 addition & 1 deletion exampleCredentials/8.revokeEntity1CredentialDirectly.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const subjectCredentialHash = tokensFactory.tokens.PSMHash(
)

//BUILD TRANSACTION updateCredentialStatus WITH transactionFactory LIBRARY
const updateCredentialStatus = transactionFactory.credentialRegistry.updateCredentialStatus(
const updateCredentialStatus = transactionFactory.credentialRegistry.updateIssuerCredential(
web3,
issuerCredentialHash,
configData.updateIssuerCredentialTo
Expand Down
2 changes: 1 addition & 1 deletion exampleCredentials/PSMHashEntity1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"psmhash":"0xe0d3d1ac343f15862d3c08fd213c9af2447be86d38c8cba53ee16c87bb78a0f7","jwt":"eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksiLCJraWQiOiJkaWQ6YWxhOnF1b3I6cmVkdDoxMmVlYUNDQTllRWJCNzhlQjk3ZDdjYWM2YiNrZXlzLTEiLCJqd2siOiIweDM1NmUzZmNlNDM1ZDg3MjkwNjJlNTJkMjYzYzBjNzA1YjNjNWUyMDFhOWE5NjA4Y2RiMDcwNzY0ZTZiOGRmMzBhZTg0MjNiNDM5YTdhZjJiY2MzNTI5Nzc4MzQxYWIwNmMxZTQ0NDExMzUyZjIxN2I2OGNlNDRhNjczYTFkZjYzIn0.eyJqdGkiOiJodHRwczovL3d3dy5lbnRpdHkuY29t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jA4Y2RiMDcwNzY0ZTZiOGRmMzBhZTg0MjNiNDM5YTdhZjJiY2MzNTI5Nzc4MzQxYWIwNmMxZTQ0NDExMzUyZjIxN2I2OGNlNDRhNjczYTFkZjYzIn0.eyJqdGkiOiJodHRwczovL3d3dy5lbnRpdHkuY29tL2FsYXN0cmlhL2NyZWRlbnRpYWxzLzM3MzQiLCJpc3MiOiJkaWQ6YWxhOnF1b3I6cmVkVDo0ODIwYWU5NDJkMjMyODdjODRlOGMzYjA4ZDQxNWMxMmU3NjE3ZmI1Iiwic3ViIjoiZGlkOmFsYTpxdW9yOnJlZHQ6MHgxMmVlYUNDQTllRWJCNzhlQjk3ZDdjYWM2YiIsImlhdCI6MTczMTMzOTI1NCwiZXhwIjoxNTYzNzgzMzkyLCJuYmYiOjE3MzEyNTI4NTQsInZjIjp7IkBjb250ZXh0IjpbImh0dHBzOi8vd3d3LnczLm9yZy8yMDE4L2NyZWRlbnRpYWxzL3YxIiwiaHR0cHM6Ly9hbGFzdHJpYS5naXRodWIuaW8vaWRlbnRpdHkvY3JlZGVudGlhbHMvdjEiLCJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSIsImh0dHBzOi8vdzNpZC5vcmcvZGlkL3YxIl0sInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiLCJBbGFzdHJpYVZlcmlmaWFibGVDcmVkZW50aWFsIiwiRHJpdmluZ0xpY2Vuc2UiXSwiY3JlZGVudGlhbFN1YmplY3QiOnsiU3R1ZGVudElEIjoiMTEyMzU4MTMiLCJsZXZlbE9mQXNzdXJhbmNlIjoiYmFzaWMifX19.iB48MV-KBPZJRiWYdd2OMm98-G7merPfPtYudNkYUfS1BdmnJ7JKJLjtbPNg1yi5vKsi3BYy-1rwKo36nTv0Jg"}
2 changes: 1 addition & 1 deletion exampleCredentials/PSMHashSubject1.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"psmhash":"0x3ecbe35372d223df6af30e53d92ff2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vKsi3BYy-1rwKo36nTv0Jg"}
10 changes: 5 additions & 5 deletions examplePublicKey/3.isPublicKeyValidForCertainDate.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ const configData = JSON.parse(rawdata)
const myBlockchainServiceIp = configData.nodeURL
const web3 = new Web3(new Web3.providers.HttpProvider(myBlockchainServiceIp))

if (configData.entity3 === undefined) {
if (configData.entity1 === undefined) {
console.error('You must create an Alastria ID')
process.exit(1)
}

console.log('We retrive the current public key for entity3')
const entity3PubKeyHash = `${web3.utils.sha3(configData.entity3Pubk.substr(2))}`
const getPubKTx = transactionFactory.publicKeyRegistry.getPublicKeyStatusHash(
const entity1PubKeyHash = `${web3.utils.sha3(configData.entity1Pubk.substr(2))}`
const getPubKTx = transactionFactory.publicKeyRegistry.getPublicKeyStatus(
web3,
configData.didEntity3,
entity3PubKeyHash
configData.didEntity1,
entity1PubKeyHash
)
web3.eth
.call(getPubKTx)
Expand Down

0 comments on commit 10bf4d3

Please sign in to comment.