GithubHelp home page GithubHelp logo

alastria / alastriaid-truffle-contracts Goto Github PK

View Code? Open in Web Editor NEW
2.0 11.0 4.0 947 KB

Alastria ID truffle Smart Contracts

License: MIT License

Solidity 79.27% JavaScript 19.83% Shell 0.90%
solidity blockchain smart-contracts ethereum besu truffle

alastriaid-truffle-contracts's Introduction

alastriaid-truffle-contracts's People

Contributors

alejandroalffer avatar cmoralesdiego avatar miguellzpf avatar nefera606 avatar rober12 avatar victorns69 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

alastriaid-truffle-contracts's Issues

Error deploying in local

Deploying contracts in a local node is giving an error

How to reproduce it? Can also see this gist

  • Branch develop, with last commit
  • Using node v14.16.0
  • Installing dependencies using npm install
  • (*) Using a local geth server:
geth --miner.gasprice 0 --http --http.corsdomain="https://remix.ethereum.org" --http.api web3,eth,debug,personal,net --vmdebug --datadir /tmp/geth --dev console
  • Run in another terminal: npm run migrateLocal
    * This problem has also been tested with ganache in a docker

Error

Running the last command will return the following error (geth on the left and deploy on the right):
photo_2021-07-19_18-22-28

Workaround

Before, publishing this issue, I've talked with @VictorNS69 which gave me a patch to solve this issue:

  • Update dependencies
  • Update migrations scripts (5 and 6 have been not fixed)

You can see those changes in this PR in my own repository

Probably, there is a better way of addressing this issue but we don't know how

FirstIdentityWallet Public Key is not stored

As shown in the images, the public key of the first identity created when deploying, is not storing in the public key registry Smart Contract.

image
bugPKFirst

I think the issue is that the initialize function in the PublicKeyRegistry must have 2 more arguments, "proxyAddress" and "publicKey", so when we initialize for the first time the contracts, we can pass as an arguments both data.

This change will also imply changing the migrations file (4_initialize_contracts.js)

Migrating Alastria smart contracts from truffle to hardhat

It has been decided from the architecture team to migrate the truffle repository to hardhat and continue to support the hardhat repository instead of the truffle repository.
The truffle repository will be dropped, once we have the unit tests for the publicKeyRegistry.

Clarification about proxy forward

Good afternoon.
We were studying the implementation of the repository and reading the code we have found a point that we don't uderstand.

In the implementation of the AlastriaIdentityManager.sol there is this a line of code that calls the PublicKeyRegistry function addKey.
We have understood the overall process, but we don't understand how it is possible for the forward to call the specific "addKey" function.

The function signature is the following function addKey(string memory publicKey) so we need to pass a string as a parameter.
The forward is called into the following function of AlastriaIdentityManager

function createAlastriaIdentity(bytes memory addPublicKeyCallData) public validAddress(msg.sender) isPendingAndOnTime(msg.sender) { AlastriaProxy identity = new AlastriaProxy(); identityKeys[msg.sender] = address(identity); pendingIDs[msg.sender] = 0; identity.forward(address(alastriaPublicKeyRegistry), 0, addPublicKeyCallData);//must be alastria registry call }

So our question is: what are we effectively passing with the parameter bytes memory addPublicKeyCallData and what does the 0 mean in the call identity.forward(address(alastriaPublicKeyRegistry), 0, addPublicKeyCallData)? Is the 0 a selector for the first function in the smart contract declaration?

Can you provide us a concrete example of what we are passing as the function parameter value?

Thanks in advance,

Andrea Vendrame.

Update AlastriaPublicKeyRegistry.sol to work with publicKey hashes

Update of the publicKeyRegistry to make the functions work with the hashes (keccak256) of the public keys instead of the public keys in the clear (bytes32)

For example,

However, reviewing the whole implementation of the smart contract.

GetPublicKeyStatus function modification proposal

Hello all,
In AlastriaPublicKeyRegistry.sol (located here), I have a question regarding the line 88 (here), the function getPublicKeyStatus accepts type bytes32 data of publicKey and makes the assumption that you already know the keccak256 of the input. As in every position within the contract the publicKey is passed as string and the keccak256 is computed within the function, wouldn't it more appropriate if we transform it accordingly, as presented in the code block below or there is a reason behind that?

function getPublicKeyStatus(address subject, string memory publicKey) view public validAddress(subject) returns (bool exists, uint status, uint startDate, uint endDate)
 PublicKey storage value = publicKeyRegistry[subject][getKeyHash(publicKey)];
 return (value.exists, value.status, value.startDate, value.endDate);
}

Thank you.

Create a new module to recover identities

Create a new module to recover identities.

This module should manage all the actions that identity recovery needs.

This includes:

  • Manage allowed recovery entities
  • Recover an account
  • Stop a recovery

Update AlastriaIdentityManager.sol so that the create AlastriaID call is made with the hash of the public key

Review the createAlastriaID function that is currently being passed memory addPublicKeyCallData bytes and probably need to make a new function that passes as parameter the hash of the public key instead of the public key in clear.

The code can be viewed at the following link

Modify recovery for the next deploy

Only the "firstIdentityWallet" can recover any account in the following version.

This means to set a new variable in the initialize and a new modifier in the recoverAccount

To complex to getPublicKeyStatus()

The second parameter is supposed to be the hash of the public key, but it is the encodedPacked hash of the string, witch is not standard outside solidity. The other methods are computing this hash internally and the parameter is the public key as string memory.

It's odd to have to manually convert the string to bytes, then the bytes to string, add the "0x" and then hash it.

The event "IdentityCreated" is never used

The IdentityManager Contract never uses the event IdentityCreated.

It should be used in this function:

function createAlastriaIdentity(bytes memory addPublicKeyCallData) public validAddress(msg.sender) isPendingAndOnTime(msg.sender) {
AlastriaProxy identity = new AlastriaProxy();
identityKeys[msg.sender] = address(identity);
pendingIDs[msg.sender] = 0;
identity.forward(address(alastriaPublicKeyRegistry), 0, addPublicKeyCallData);//must be alastria registry call

Create unit test to AlastriaPublicKeyRegistry.sol

It is necessary to create a series of tests to verify that the behaviour of the AlastriaPublicKeyRegistry.sol smart contract works as expected.

These tests need to be created in the following folder:
https://github.com/alastria/alastriaID-truffle-contracts/tree/develop/tests/registry
with the following name: AlastriaPublicKeyRegistry.ts

Currently there are unit tests for the AlastriaCredentialRegistry.sol and AlastriaPresentationRegistry.sol smart contracts that test all the functionality of these smart contracts including the optional anchoring of credentials and presentations. (the latest functionality included in these smart contracts)

Create a new smart contract called AlastriaObjectRegistry.sol

This smart contract will unify the AlastriaCredentialRegistry.sol and AlastriaPresentationRegistry.sol smart contracts.
It will store only the hash and the state of the objects without distinguishing which object is being talked about.

For this it is also necessary to unify the states of both smart contracts and change them from an enum to a numeric value. Later, in comments, we will mark the meaning of each state for credentials and presentations.

Create a "How To" section in the documentation

We should add a new section called "How To" to explain the deployment and the upgrade process of the Smart Contracts.

Some important aspects in this documentation are:

  • Enumerate the steps involving the upgradeability
  • Detailed explanation about "what are we doing this"

Also, it would be a good idea to explain the proxy pattern we are using (openzeppeling) and how we are using it in Alastria.

Review credential and presentation registry unit tests

Review the AlastriaCredentialRegistry and AlastriaPresentationRegistry unit tests as they were developed on hardhat and this repository is truffle.

These already developed tests must be saved for reuse in the new alastriaID-hardhat-contracts repository that is pending to be created. (https://github.com/alastria/alastriaID-truffle-contracts/tree/develop/tests/registry)

In order not to work from scratch, you can take the unit tests of the old smart contracts and adapt them. (https://github.com/alastria/alastria-identity/tree/master/test/registry)

Migrate to Hardhat

Migrate project to hardhat (instead of truffle).

We can also, keep 2 versions (if we want to), one with truffle, other with hardhat.

DeleteSubjectCredential when used does not remove the credential from the subjectCredentialList

Hello all,
When the DeleteSubjectCredential smart contract function (located here is used, the credential is marked as DeletedBySubject (assigning the status of the credential equals to 3), but it is not removed from the subjectCredentialList. After a successful deletion by the subject, the subjectCredentialList retains the removed credential. Shouldn't the removed credentials also been removed from the list too?
Thank you very much

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.