Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Construction API (formerly Wallet API) #21

Merged
merged 18 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 224 additions & 8 deletions README.md

Large diffs are not rendered by default.

589 changes: 569 additions & 20 deletions api.json

Large diffs are not rendered by default.

426 changes: 409 additions & 17 deletions api.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ OUTPUT_FILE=api.json
swagger-cli bundle api.yaml -o "${OUTPUT_FILE}";

# Remove newlines from descriptions
sed "${SED_IFLAG[@]}" 's/\\n\\n/\\n/g' "${OUTPUT_FILE}";
sed "${SED_IFLAG[@]}" 's/\\n/ /g' "${OUTPUT_FILE}";
sed "${SED_IFLAG[@]}" 's/ "/"/g' "${OUTPUT_FILE}";
23 changes: 23 additions & 0 deletions models/CurveType.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2020 Coinbase, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

description: |
CurveType is the type of cryptographic curve associated with a PublicKey.

* secp256k1 = SEC compressed 33-bytes.
* edwards25519 = y (255-bits) || x-sign-bit (32-bytes).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way this is documented is a little bit confusing which is my bad for stating it like this in the other doc.

This reads like the public key is 255-bits + 32-bytes which isn't true. It's 255-bits + 1-bit for a total of 32-bytes. It may be worth clarifying that here.

It also could be beneficial to link to documentation on where these encodings are described elsewhere.

For Ed25519, it's page 6 of the paper here: https://ed25519.cr.yp.to/ed25519-20110926.pdf
For secp256k1, the compressed encoding is here: https://secg.org/sec1-v2.pdf#subsubsection.2.3.3

type: string
enum:
- secp256k1
- edwards25519
32 changes: 32 additions & 0 deletions models/PublicKey.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2020 Coinbase, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

description: |
PublicKey contains a public key byte array
for a particular CurveType encoded in hex.

Note that there is no PrivateKey struct as this
is NEVER the concern of an implementation.
type: object
required:
- hex_bytes
- curve_type
properties:
hex_bytes:
type: string
description: |
Hex-encoded public key bytes in the format
specified by the CurveType.
curve_type:
$ref: "CurveType.yaml"
36 changes: 36 additions & 0 deletions models/Signature.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2020 Coinbase, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

description: |
Signature contains the payload that was signed, the public keys of the
keypairs used to produce the signature, the signature (encoded in hex),
and the SignatureType.

PublicKey is often times not known during construction of the signing payloads
but may be needed to combine signatures properly.
type: object
required:
- signing_payload
- public_key
- signature_type
- hex_bytes
properties:
signing_payload:
$ref: "SigningPayload.yaml"
public_key:
$ref: "PublicKey.yaml"
signature_type:
$ref: "SignatureType.yaml"
hex_bytes:
type: string
25 changes: 25 additions & 0 deletions models/SignatureType.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2020 Coinbase, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

description: |
SignatureType is the type of a cryptographic signature.

* ecdsa = r (32-bytes) || s (32-bytes)
* ecdsa_recovery = r (32-bytes) || s (32-bytes) || v (1-byte)
* ed25519 = R (32-byte) || s (32-bytes)
type: string
enum:
- ecdsa
- ecdsa_recovery
- ed25519
35 changes: 35 additions & 0 deletions models/SigningPayload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright 2020 Coinbase, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

description: |
SigningPayload is signed by the client with the keypair associated
with an address using the specified SignatureType.

SignatureType can be optionally populated if there is
a restriction on the signature scheme that can be
used to sign the payload.
type: object
required:
- address
- hex_bytes
properties:
address:
type: string
description: |
The network-specific address of the account that should sign
the payload.
hex_bytes:
type: string
signature_type:
$ref: "SignatureType.yaml"