Skip to content
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
140 changes: 133 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions maint/codeql/rust/lib/imports.qll
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ private predicate isAllowlistedReexport(Use u) {
or
usePrefix(u) = "dash_types"
or
usePrefix(u) = "ed25519_dalek"
or
usePrefix(u) = "ff"
or
usePrefix(u) = "group"
Expand All @@ -100,6 +102,13 @@ private predicate isAllowlistedReexport(Use u) {
usePrefix(u) = "zeroize"
)
or
fileOf(u).getAbsolutePath().matches("%pkgs/primitives/%") and
(
// `dash-pkc` names its hashes after the curve, the alias is the public API.
usePrefix(u) = "dash_pkc" and
u.getUseTree().getPath().getSegment().getIdentifier().getText() = "__EddsaPkHash"
)
or
fileOf(u).getAbsolutePath().matches("%pkgs/script/%") and
(
// Workaround for the orphan rule, not part of public API
Expand Down
6 changes: 6 additions & 0 deletions maint/codeql/rust/lib/pkc.qll
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
*/
extensible predicate armOnly(string arm, string role, string name);

/**
* Holds if `arm` cannot carry `name` at `role`, though the other arms offer
* it. Rows live in `pkc.model.yml`.
*/
extensible predicate armLacks(string arm, string role, string name);

/**
* Holds if `arm` cannot carry `trait` at `role`, though the other arms do.
* Rows live in `pkc.model.yml`.
Expand Down
26 changes: 25 additions & 1 deletion maint/codeql/rust/pkc.model.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,31 @@ extensions:
# Recoverable signatures
- ["Ecdsa", "SecretKey", "sign_recoverable"] # Sign
- ["Ecdsa", "PublicKey", "recover"] # Get public key from a signature
- addsTo:
pack: base-sdk/codeql-rust
extensible: armLacks
data:
# Ed25519
# Tweaking
- ["Eddsa", "SecretKey", "add_tweak"] # Curve properties prevent this, see SLIP-0010
- ["Eddsa", "PublicKey", "add_tweak"] # Curve properties prevent this, see SLIP-0010
- ["Eddsa", "PublicKey", "mul_tweak"] # Curve properties prevent this, see SLIP-0010
- addsTo:
pack: base-sdk/codeql-rust
extensible: armLacksTrait
data: []
data:
# Ed25519
# Consensus wire format
- ["Eddsa", "PublicKey", "Decode"] # Not a wire type, see `Unencodable`
- ["Eddsa", "PublicKey", "Encode"] # Not a wire type, see `Unencodable`
- ["Eddsa", "PublicKey", "SerBound"] # Follows from `Decode`
- ["Eddsa", "PublicKey", "TypeId"] # Follows from `Decode`
- ["Eddsa", "SecretKey", "Decode"] # Not a wire type, see `Unencodable`
- ["Eddsa", "SecretKey", "Encode"] # Not a wire type, see `Unencodable`
- ["Eddsa", "SecretKey", "Hashable"] # Follows from `Decode`
- ["Eddsa", "SecretKey", "TypeId"] # Follows from `Decode`
- ["Eddsa", "Signature", "Decode"] # Not a wire type, see `Unencodable`
- ["Eddsa", "Signature", "Encode"] # Not a wire type, see `Unencodable`
- ["Eddsa", "Signature", "Hashable"] # Follows from `Decode`
- ["Eddsa", "Signature", "SerBound"] # Follows from `Decode`
- ["Eddsa", "Signature", "TypeId"] # Follows from `Decode`
7 changes: 6 additions & 1 deletion maint/codeql/rust/pkc.ql
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,24 @@ predicate shapeGap(TypeItem lacks, string role, string name, string arm) {
lacking != arm and
publicMethod(offers, name) and
not publicMethod(lacks, name) and
not armOnly(arm, role, name)
not armOnly(arm, role, name) and
not armLacks(lacking, role, name)
)
}

/**
* Holds if `lacks` is missing `trait`, which `arm` carries for the same role
* inclusive of derives gated by `cfg_attr`.
*
* Double-underscore traits are skipped, considered private implementation
* concerns not part of the public API.
*/
predicate traitGap(TypeItem lacks, string role, string trait, string arm) {
exists(TypeItem offers, string lacking |
armRole(offers, arm, role) and
armRole(lacks, lacking, role) and
lacking != arm and
not trait.matches("\\_\\_%") and
implementsPlainTrait(offers, trait) and
not implementsPlainTrait(lacks, trait) and
not hasDerive(lacks, trait) and
Expand Down
9 changes: 8 additions & 1 deletion pkgs/pkc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ group = { version = "0.14", default-features = false, optional = true }
cfg-if = "1"
dash-num = { version = "0.1.0-beta", path = "../num", default-features = false }
dash-types = { version = "0.1.0-beta", path = "../types", default-features = false }
ed25519-dalek = { version = "3", default-features = false, features = [
"fast",
"rand_core",
"signature",
"zeroize",
], optional = true }
hex-conservative = { workspace = true, features = [
"alloc",
] }
Expand Down Expand Up @@ -65,8 +71,9 @@ codec = [
"dash-types/codec",
]
ecdsa = ["dep:rand_core", "dep:secp256k1"]
eddsa = ["dep:ed25519-dalek", "dep:rand_core"]
serde = ["codec", "dep:serde", "dash-num/serde", "dash-types/serde"]
full = ["bls", "codec", "ecdsa", "serde", "std", "tests"]
full = ["bls", "codec", "ecdsa", "eddsa", "serde", "std", "tests"]
tests = ["std", "dep:rstest"]

[lints]
Expand Down
Loading