-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Specification
In order to form a network securely, we need some way to verify cryptographically whether a node should be able to access a network. To do this we need to make use of tokens as a portable, scale-able and secure method for proving access to a network. To do this the tokens need to encode details about the network authority, the subject node and provide a signature.
For out needs, we need a single network authority that defines the network itself. The details of this can be decided but all we require is a secure key pair to act as the trust anchor for the network authority. But we need to be able to issue access tokens in a decentralized way. Ideally using seed nodes issues for network access tokens.
We are going to be doing this with 2 types of tokens:
ClaimNetworkAuthority- This is a token issued by the network authority authorizing the ability for nodes to mintClaimnetworkAccesstokens.ClaimNetworkAccess- This token is minted for a specific node to prove access to a network.
Both tokens are required to be provided as a token chain to prove access to a network. They need to encode the following facts to prove this. Note that the ids for all purposes will just be NodeIds of nodes in the network as a way to identify a node and key interchangeably.
- The id/publicKey for the network authority. Its use to verify and identify the network
- The id/publicKey of the minter for the network access token.
- The id/publicKey of the node that gains access to the network.
- Signature from the network authority.
- Signature from the minter node.
Minting tokens
The ClaimNetworkAuthority token exists to prove that a node can mint tokens on the authority of the network. This means minters can be dynamic and not know ahead of time so long as they hold the authority token and the authority is known. This is important for dynamic scaling of minter nodes.
In the most basic form this ClaimNetworkAuthority needs to encode the following information.
- type=ClaimNetworkAuthority - indicating that the claim is a
ClainNetworkAuthority. - iss: The id/publicKey of the network authority.
- sub: the id/publicKey of the minter node.
- signature created with the privateKey of the network authority (iss).
Succinctly this proves that the subject (sub) has the authority of the network authority (iss) to mint access tokens for that network. This is verified with the signature. This for fills the facts 1, 2 and 4 above.
The ClaimNetworkAccess token exists to prove that a node has access to the network. This can be issued by any node that has a valid ClaimNetworkAuthority token.
In its most basic form the ClaimNetworkAccess token needs to encode the following information.
- type=ClaimNetworkAccess - indicating that the claim is a
ClaimNetworkAccess. - iss: The id/publicKey of the minter node.
- sub: the id/publicKey of the authorised node.
- signature created with the privateKey of the minter node (iss).
Succinctly this proves that the subject (sub) has access to the network under the authority of the network authority. This is verified with the signature. This for fills the facts 2, 3 and 5. Note that the fact 2 is common between the two claims and helps verify the chain.
The ClaimNetworkAccess needs to include extra metadata refers the ClaimNetworkAuthority in some way. While this data isn't strictly required to verify the chain. It should provide a way to find all the required information needed to verify the chain. This can take two forms.
- Embed the
ClaimNetworkAuthorityclaim within theClaimNetworkAccessclaim. Simple but bloats the information. - Include the
claimIdof theClaimNetworkAuthority, TheNodeIdof the node we can get the token from. And optionally a hash of the token.
So long as the verify-er has the contents of both tokens then it can verify it.
Verifying tokens
Much like a certificate chain in TLS, the tokens form a token chain. Where verifying the tokens in order can prove a chain of trust that verifies access to a network. To verify all of the following facts.
- Check the TLS certificate of the node connecting and asking for access to extract the
NodeId. - Check the
subof theClaimNetworkAccesstoken matches the connected node. - Check the signature of the
ClaimNetworkAccesstoken is signed buy it'siss. - Check that the
issof theClaimNetworkAccesstoken matches thesubof theClaimNetworkAuthoritytoken. - Check that the
issof theClaimNetworkAccesstoken matches the network we are authorised under. - Check that the signature of the
claimNetworkAccesstoken is signed bu theiss.
If all these facts are true and the network matches one we allow then we allow the connection. Otherwise we reject and kill the connection.
To expand on this we may want to enforce a strict mode where we only allow the node to access a single network. To do this we can can requests the access tokens as part of their sigchain. If we only see one network access token within their chain then that meets the strict condition.
Additional context
Parent: #770
Tasks
- Create a structure for
ClaimNetworkAuthorityandClaimNetworkAccessclaims within theclaimsdomain. - Add logic for minting these claims.
- Add a utility for verifying these claims.