Giter Club home page Giter Club logo

reverse-hash-service's Introduction

reverse-hash-service

The Reverse Hash Service (RHS) is a service that stores iden3 identity public states (identity state and public nodes of revocation tree and roots tree). This service aims to enhance privacy of credential revocation status checks for identities. https://docs.iden3.io/services/rhs/

Run service

# create database
createdb rhs && psql -d rhs < ./schema.sql

# default database URL is postgers://rhs@localhost with local auth
export RHS_DB="host=localhost password=pgpwd user=postgres database=rhs"

# default listen address is :8080
# export RHS_LISTEN_ADDR=:8080

go build && ./reverse-hash-service

Run service with docker-compose.yml file

# Run docker-compose
docker-compose up -d

# Copy schema.sql to container with postgres
docker cp schema.sql <db_container_name>:/

# Exec to container
docker exec -it <db_container_name> /bin/bash

# Create rhs db
createdb -U iden3 -h localhost rhs 

# Upload schema.sql inside on docker container
psql -h localhost -U iden3  -d rhs < schema.sql

Save new hashes

curl -H "Content-Type: application/json" -X POST localhost:8080/node -d '[
  {
    "hash": "e33d2335edfc794a855cbfd235a7e9e8ea433e569591012cd743c17fa6a02b1e",
    "children": [
      "5fb90badb37c5821b6d95526a41a9504680b4e7c8b763a1b1d49d4955c848621",
      "65f606f6a63b7f3dfd2567c18979e4d60f26686d9bf2fb26c901ff354cde1607"
    ]
  },
  {
    "hash": "c5df774d59b69814c679868deaf42354dc5de89e34088c4a1dbbf362d703b314",
    "children": [
      "5d27606e29afb1fde4f6764fa0a01eec23e11dafffabae96ed2ae7229aa5992a",
      "bc4dd02832954c16a6ce4c48da20fe517e822caa6dc3fabfcdf9684443321002"
    ]
  }
]'
# Output:
# {"status":"OK"}

Retrieve hash

curl localhost:8080/node/e33d2335edfc794a855cbfd235a7e9e8ea433e569591012cd743c17fa6a02b1e
# Output:
# {
#   "status": "OK",
#   "node": {
#     "hash": "e33d2335edfc794a855cbfd235a7e9e8ea433e569591012cd743c17fa6a02b1e",
#     "children": [
#       "5fb90badb37c5821b6d95526a41a9504680b4e7c8b763a1b1d49d4955c848621",
#       "65f606f6a63b7f3dfd2567c18979e4d60f26686d9bf2fb26c901ff354cde1607"
#     ]
#   }
# }

Utility

To fetch and generate merkle proofs, you can use the following utility library:

https://github.com/iden3/merkletree-proof

import (
    "github.com/iden3/merkletree-proof"
)


stateHash, _ := merkletree.NewHashFromHex("e12084d0d72c492c703a2053b371026bceda40afb9089c325652dfd2e5e11223")

cli := &merkletree_proof.HTTPReverseHashCli{URL: "<link to RHS>"}
// get identity state roots

stateValues, err := cli.GetNode(ctx, stateHash)

Contributing

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.

License

reverse-hash-service is part of the iden3 project copyright 2023 0kims Association

This project is licensed under either of

at your option.

reverse-hash-service's People

Contributors

olomix avatar vmidyllic avatar ilya-korotya avatar demonsh avatar

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.