A simple script to create Gaia-X Self Descriptions

Overview

How To Use

  1. Update the self description in self-description.json.
  2. Create a new .env file with PRIVATE_KEY, CERTIFICATE, VERIFICATION_METHOD and X5U_URL as properties.
  3. Install dependencies npm i and execute the script node index.js (node@16 or higher required).
    • Alternatively, the script can be run with docker
      1. Build the container with docker build -t self-description-signer .
      2. Run the script with docker run -it --mount src="$(pwd)/config",target=/usr/src/app/config,type=bind self-description-signer
  4. The given self description will be locally signed and a new file containing self description + proof called timestamp_self-signed_gx-type.json will be created.
  5. In addition, a did.json will be created based on the provided CERTIFICATE and VERIFICATION_METHOD
  6. Upload this did.json to your domain (e.g. https://your_domain.com/.well-known/did.json).
  7. Re-run the script and finally, the compliance service is used to sign the locally signed self description. It signs it if the final result is against the compliance service. The result is stored in a new file called timestamp_complete_gx-type.json

How it Works

  1. The given Self Description is canonized with URDNA2015
  2. Next the canonized output is hashed with SHA256.
  3. That hash is then signed with the given private key and the proof is created using JsonWebKey2020.
Comments
  • [BUG] Problems with self signed certificates

    [BUG] Problems with self signed certificates

    Summary

    Hi! I have some problems when I try to use this signing tool (I was follow gx-compliance repository).

    I tried to generate private/public keys using openSSL and then generate a self signed certificate, the content of these keys are used in .env file.

    I used the following script to generate keys/cert:

    openssl genrsa -out keypair.pem 2048
    openssl rsa -in keypair.pem -pubout -out publickey.crt
    openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in keypair.pem -out pkcs8.key
    
    openssl req -new -key pkcs8.key -out my_request.csr
    openssl x509 -req -days 3650 -in my_request.csr -signkey pkcs8.key -out cert.key
    
    rm my_request.csr
    

    So, using the previous script the key was in PKCS8 format. I think thats correct. Isnt it? Anyway, I have modified the code (env and index.js) to add a variable JWT_ALGORITHM inside the .env file (so I can switch to use for example X509)... but I have tried to change this variable and change the method to generate keys and it still fails.

    Current Behavior

    Fails when try to check self description with the Compliance Service:

    ๐Ÿ“ Loaded ./config/self-description.json
    ๐Ÿ“ˆ Hashed canonized SD 1efd1a5039805ed10455271e11ade83d2a6e044761c25da5cb1ecc4b6294e8b1
    ๐Ÿ”’ SD signed successfully (local)
    โœ… Verification successful (local)
    ๐Ÿ“ ./output/1663918326577_self-signed_LegalPerson.json saved
    ๐Ÿ“ ./output/1663918326577_did.json saved
    
    ๐Ÿ” Checking Self Description with the Compliance Service...
    'Something went wrong:'
    {
      statusCode: 409,
      message: 'Verification for the given jwk and jws failed.',
      error: 'Conflict'
    }
    

    Expected Behavior

    A successful process

    Steps to Reproduce

    node ./index.js after modify self-description.json and env file.

    Environment

    PRIVATE_KEY="-----BEGIN PRIVATE KEY-----
    MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCz8c/UjRnLRIm0
    V5XZrX+YtEe57pjtjkjhs3kDpKI8gw04jtr+XHtxF1dPykdYG/WzIpk8KNW5U6Ci
    ...
    Q7RgZby31d1Sok6YubMMdtDa0eDVaSdFEIfr+LdFzBHC9RGt/FJLvdhHCOUNHnAl
    FKYM055z0JJC4wZdCSYmPQSumIPHfcJWaKKMnDvsVHoh7tNtOLAX9BrFgHolsY3+
    +1zPmXn1KZuyolUXHKpMjPRc
    -----END PRIVATE KEY-----"
    CERTIFICATE="-----BEGIN CERTIFICATE-----
    MIIDfTCCAmUCFEb5J7SaEulAVI/WltT09D4cWBT7MA0GCSqGSIb3DQEBCwUAMHsx
    ...
    nMO89712xzIR64Ch5DI5yKCQ5NVFDUUrcfqvrWd2hzAU723VxPEHu6jlD8ISKTJI
    MwGwF/i9VqRwGiAMv6+1QjqXazjCiXX4KJQP2czY1fSN
    -----END CERTIFICATE-----"
    JWT_ALGORITH="PS256" #PS256 or ES256 (X509)
    VERIFICATION_METHOD="did:web:compliance.gaia-x.eu"
    X5U_URL="https://compliance.gaia-x.eu/.well-known/x509CertificateChain.pem"
    API_VERSION="2204"
    BASE_URL="https://compliance.gaia-x.eu"
    

    Anything else

    When i used yours Hackaton tool everything works!

    Also, my self description is the following one:

    {
        "@context": [
            "http://www.w3.org/ns/shacl#", 
            "http://www.w3.org/2001/XMLSchema#", 
            "http://w3id.org/gaia-x/participant#"
        ],
        "@id": "http://example.org/participant-dp6gtq7i75lmk9p4j2tfgCTICTICTIC2",
        "@type": [
            "VerifiableCredential", 
            "LegalPerson"
        ],
        "credentialSubject": {
          "id": "did:web:examnple.com",
          "gx-participant:registrationNumber": {
            "@value": "G-33906637",
            "@type": "xsd:string"
        }, 
          "gx-participant:headquarterAddress": {
            "@type": "gx-participant:Address",
            "gx-participant:country": {
              "@type": "xsd:string",
              "@value": "ES"
            },
            "gx-participant:street-address": {
                "@value": "C. Ada Byron, 39",
                "@type": "xsd:string"
            },
            "gx-participant:postal-code": {
                "@value": "33203",
                "@type": "xsd:string"
            },
            "gx-participant:locality": {
                "@value": "Gijon",
                "@type": "xsd:string"
            }
          },
          "gx-participant:legalAddress": {
            "@type": "gx-participant:Address",
            "gx-participant:country": {
              "@type": "xsd:string",
              "@value": "ES"
            },
            "gx-participant:street-address": {
                "@value": "C. Ada Byron, 39",
                "@type": "xsd:string"
            },
            "gx-participant:postal-code": {
                "@value": "33203",
                "@type": "xsd:string"
            },
            "gx-participant:locality": {
                "@value": "Gijon",
                "@type": "xsd:string"
            }
          }
        }
      }
    

    Thanks a lot!!!

    Type: Bug 
    opened by Javieral95 22
  • refactor: switched id controller value in did

    refactor: switched id controller value in did

    Proposed Changes

    Switch the value of id and controller in did verfication method to conform to the specification.

    A controller is an entity that is authorized to make changes to a DID Document (https://www.w3.org/TR/did-core/#did-controller)

    A DID is expressed using ID and which allows theoretically DID that are not part of the subject DID (https://www.w3.org/TR/did-core/#did-subject) but since for Assertion Methods (https://www.w3.org/TR/did-core/#assertion) when used in the short form of "did:example..." the allowed did must match an ID of an Verification Method (or explicit define a new Verification Method under Assertion) even on the earlier stages it makes more sence to have the ID from the DID Subject and the Controller to be the complicance service.

    See also the note on the did core spec:

    "NOTE: Verification method controller(s) and DID controller(s) The semantics of the controller property are the same when the subject of the relationship is the DID document as when the subject of the relationship is a verification method, such as a cryptographic public key. Since a key can't control itself, and the key controller cannot be inferred from the DID document, it is necessary to explicitly express the identity of the controller of the key. The difference is that the value of controller for a verification method is not necessarily a DID controller. DID controllers are expressed using the controller property at the highest level of the DID document (the topmost map in the data model); see ยง 5.1.2 DID Controller."

    opened by sdumss 0
  • added a draft for docker usage

    added a draft for docker usage

    Proposed Changes

    Added support for lacy people who donโ€™t want to deal with node

    example docker commands

    docker build -t . docker run -it --mount src="$(pwd)/config",target=/usr/src/app/config,type=bind

    opened by sdumss 0
  • Fix incorrect DID Document generation and examples.

    Fix incorrect DID Document generation and examples.

    The signer creates the DID Documents incorrectly. The Verification Relationship (asertionMethod), points to a VM that does not exist in the DID Document.

    • Added new variables for a DID, which could be used as the only param for DID creation.
    • Also fixed the examples and updated the self description DID to another value, as it could be highly confusing to new people to us the compliance service DID:web for the examples.

    Warning: Do not merge yet as the changes have not been tested yet.

    opened by nklomp 0
  • WIP: Support ecdsa

    WIP: Support ecdsa

    Trying to implement ECDSA because of #21

    Signing works. local verification not.

    In the end, it's pointless anyway, because the server part of the whole thing has to be able to do ECDSA.

    THIS CODE DOES NOT WORK!

    opened by kettenbach-it 0
  • [BUG] Method sign() not returning jws

    [BUG] Method sign() not returning jws

    Summary

    Trying to sign SD I've always got an error during the process

    'Something went wrong:' undefined

    after a short debugging session i saw that the sign() method did not return the jsw string and the procedure failed without triggering any error/exception. The cause of this behavior is to be found in the scope of the declaration of the variable jws which is inside a try/catch block and when it is returned is no longer valued(=undefined).

    The workaround I've adopted to fix the problem is to move the declaration of jws outside the try/catch block.

    image

    I hypothesize that this behavior is due to the relatively new version of Node.js (16.16.0) that I have been using lately.

    Hope this help.

    Regards

    Pietro

    Environment

    • OS: Windows 11
    • Node: 16.16.0
    • npm: 8.11.0
    Type: Bug 
    opened by bartoccioni 0
  • [Enhancement] Support for ECDSA Keys because EDC requires them

    [Enhancement] Support for ECDSA Keys because EDC requires them

    Motivation / Problem

    The Eclipse Dataspace Connector (EDC) requires the users to use EC signatures instead of RSA. The self-description-signer does not support EC keys:

    โฏ node index.js
    ๐Ÿ“ Loaded ./config/self-description.json
    ๐Ÿ“ˆ Hashed canonized SD 8fc77f3ec2a1add9803dd55cc8d833c916521d2310f7e93e8310c5f21920e07c
    TypeError: Invalid key for this operation, its asymmetricKeyType must be rsa or rsa-pss
        at keyForCrypto (self-description-signer/node_modules/jose/dist/node/cjs/runtime/node_key.js:53:23)
        at sign (self-description-signer/node_modules/jose/dist/node/cjs/runtime/sign.js:23:91)
        at FlattenedSign.sign (self-description-signer/node_modules/jose/dist/node/cjs/jws/flattened/sign.js:68:55)
        at CompactSign.sign (self-description-signer/node_modules/jose/dist/node/cjs/jws/compact/sign.js:14:43)
        at sign (self-description-signer/index.js:48:14)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
        at async createProof (self-description-signer/index.js:63:10)
        at async main (self-description-signer/index.js:173:19)
    
    

    Therefore I can't use the web:dids for EDC.

    Solution

    self-description-signer should support EC keys.

    Alternatives

    None

    Additional context

    Pull request for logging key signing errors: https://github.com/deltaDAO/self-description-signer/pull/22

    Type: Enhancement 
    opened by kettenbach-it 1
  • [BUG] Problem with command line parsing

    [BUG] Problem with command line parsing

    Summary

    I want to supply the name of the file containing my self description as a command line parameter. From the index.js I see, that this is supposed to work as third parameter.

    I keep the program in a unmodified subdirectory self-description-signer (created by git submodule add) - all files that I work with are outside of this git repo.

    My config therefore is in ./config (outside of self-description-signer)

    Current Behavior

    I call this command:

    โฏ node self-description-signer/index.js ./participant-self-description.json
    node:internal/modules/cjs/loader:936
      throw err;
      ^
    
    Error: Cannot find module './participant-self-description.json'
    Require stack:
    - /Users/volker/Huawei/Boot-X/boot-x-iac/Self Description Signing/self-description-signer/index.js
        at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
        at Function.Module._load (node:internal/modules/cjs/loader:778:27)
        at Module.require (node:internal/modules/cjs/loader:1005:19)
        at require (node:internal/modules/cjs/helpers:102:18)
        at Object.<anonymous> (/Users/volker/Huawei/Boot-X/boot-x-iac/Self Description Signing/self-description-signer/index.js:10:25)
        at Module._compile (node:internal/modules/cjs/loader:1101:14)
        at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
        at Module.load (node:internal/modules/cjs/loader:981:32)
        at Function.Module._load (node:internal/modules/cjs/loader:822:12)
        at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
      code: 'MODULE_NOT_FOUND',
      requireStack: [
        '/Users/volker/Huawei/Boot-X/boot-x-iac/Self Description Signing/self-description-signer/index.js'
      ]
    }
    

    and get an error. The same with node self-description-signer/index.js participant-self-description.json or with node self-description-signer/index.js $PWD/participant-self-description.json

    Expected Behavior

    I would expect my file ./participant-self-description.json to be signed. Strangely, if I leave out the third parameter, it will sign the example in self-description-signer/config and put the output to output

    Steps to Reproduce

    Enter the above commands.

    Environment

    โฏ node -v
    v16.13.0
    

    Anything else

    Type: Bug 
    opened by kettenbach-it 0
  • DID file Ftp server upload

    DID file Ftp server upload

    Good morning,

    This is Mario from Arsys Spain, I belong to Sara Madariaga's team and I recently started working in Arsys self-descriptions files for the Gaia-X project.

    First of all, let me thank you for sharing this tool, We've been working on this issue just for a few weeks and it's been really useful for us to understand how the signing process works and all the steps we have to follow to complete it.

    I would like to share a little update we developed in our side for testing our files, maybe it may be helpful for other people who are getting into Gaia-X world and begin to use this tool.

    In short, the generated DID file can be uploaded directly to the server (if configuration is enabled) so it's not neccesary for you to run the script twice to complete the process.

    I hope we can keep in touch, and thanks a lot for your time.

    Take care and best regards,

    Proposed Changes

    • library ssh2-sftp-client
    • FTP config values in .env file
    • index.js will try to update the file if FTP_ENABLED is set to true
    opened by mpetruzzella 1
Owner
deltaDAO
deltaDAO
Convert olymp.sty based TeX problem files to BOJ Stack descriptions

boj-description-converter solved-ac.github.io/boj-description-converter Convert UCPC-flavored olymp.sty based TeX problem statements to HTML, complyin

solved.ac 10 Oct 2, 2022
๐Ÿš€ Get 3000+ crypto currency information. Decimals, descriptions, website, contract ane etc...!

Crypto currency data information Description ?? Get 3000+ crypto currency information. Decimals, descriptions, website, contract ane etc...! Install n

Steven Green 6 Aug 14, 2022
I'm trying to create simple program for adding the digital signature to a pdf file with self-signed certificate. I use node-signpdf and pdf-lib library.

pdf-digital-signature-with-node-signpdf-ejs I'm trying to create simple program for adding the digital signature to a pdf file with self-signed certif

null 5 Dec 25, 2022
Script to fetch all NFT owners using moralis API. This script output is a data.txt file containing all owner addresses of a given NFT and their balances.

?? Moralis NFT Snapshot Moralis NFT API will only return 500 itens at a time when its is called. For that reason, a simple logic is needed to fetch al

Phill Menezes 6 Jun 23, 2022
Script to synchronize between a Notion database and Google Calendar both ways. Uses Google App Script.

Yet Another Two Way Notion-Google Calendar Sync Script A script to sync events between Google calendar and a Notion database. Features! Google App Scr

kat 41 Jan 7, 2023
Create a self-maintaining index via proxy

proxy-indexer Proxy-indexer allows you to easily index collections of mutable objects based on their own mutable properties. While this is relatively

Anthony Manning-Franklin 5 Nov 18, 2022
A simple self-use pull template project

English | ็ฎ€ไฝ“ไธญๆ–‡ temp_manage A simple self-use pull template project. Supports github, gitlab, Bitbucket If you have an excellent template project, you

wegi8 7 Jul 21, 2022
Integrate Tailwind with the @wordpress/create-block script.

Tailwind Blocks Example plugin demonstrating how to integrate Tailwind with the @wordpress/create-block script. The plugin was scaffolded using @wordp

David Gwyer 25 Nov 13, 2022
This is a simple script to upload Multiple files into google drive using google drive API and Nodejs.

Welcome to gDrive Multiple File Upload ?? This is a simple script to upload Multiple files into google drive using google drive API and Nodejs Install

Jayamal Sanuka Hettiarachchi 1 Dec 29, 2021
A simple npm script to generate an .editorconfig file.

Create EditorConfig A simple npm script to generate an .editorconfig file. You don't know EditorConfig? Check out the official documentation! Usage Si

Douglas Moura 7 Dec 7, 2022
Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls.

Hash.js - URL Hash Manipulation Hash.js is a 0.5 KB script that lets you in a super simple way manipulate everything behind # in urls. Tested in lates

Jonny Strรถmberg 152 Aug 1, 2022
A Simple yet extendable jQuery modal script built for use with inline HTML, images, videos, and galleries.

jQuery Chaos Modal A Simple yet extendable jQuery modal script built for use with inline HTML, forms, and images in mind. There are many other modal p

Matthew Sigley 3 Oct 8, 2020
A fancy self-hosted monitoring tool

Uptime Kuma It is a self-hosted monitoring tool like "Uptime Robot". Features Monitoring uptime for HTTP(s) / TCP / Ping. Fancy, Reactive, Fast UI/UX.

Louis Lam 27.4k Jan 3, 2023
A self-hosted solution for backing up and viewing backed up mobile photos

Photostore Photostore is a self-hosted, client-server solution for backing up, viewing and downloading photos. How it works The Photostore API (writte

null 38 Oct 25, 2022
Like Obsidian Publish but for self-hosting. Plugin integrations for dataview, admonition, and more.

Obsidian Export Obsidian Publish is great but lacks support for many of the plugins we Obsidian addicts have grown accustomed to โ€” in particular Datav

null 12 Nov 28, 2022
Self-rendering and distributable mathematics chalkboards

Muboard Muboard is a tiny utility that runs a mathematics display board as a web page. Muboard lets you quickly scribble mathematics snippets using Ma

Susam 539 Dec 15, 2022
Open-source continuous regression testing that you can self-host.

Touca Touca helps you see the side-effects of your changes, as you write code. Touca SDKs let you describe the behavior and performance of your softwa

Touca 135 Dec 30, 2022
DropSpace is an easy way to self-host a file drop.

DropSpace Simple file sharing made in Laravel About DropSpace DropSpace is an easy way to self-host a file drop. Simply upload your file, and share th

Kazรณ Levente 25 Dec 9, 2022
A minimal & self-hostable alternative to pastebin intended for code

minBin A minimal & self-hostable alternative to pastebin intended for code Use โŒจ๏ธ A public instance is available at https://bin.kio.dev/ Building ?? n

Kio 4 Dec 29, 2022