mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
354fdabdc4 | ||
|
|
7c4586ce90 | ||
|
|
6d27b926f6 | ||
|
|
f74bdc1d79 | ||
|
|
8522cb8d47 | ||
|
|
30475b9fbd | ||
|
|
1388a673e5 | ||
|
|
ac8c153b28 | ||
|
|
ee12bf684e | ||
|
|
63dc68caac | ||
|
|
ec57c76a2a | ||
|
|
99e9eefffb | ||
|
|
eb0777ebb4 | ||
|
|
ed5ee034b8 | ||
|
|
bb2972b527 | ||
|
|
45b474c9a6 | ||
|
|
99747c022e | ||
|
|
d9a2689469 | ||
|
|
08d8c7eda0 | ||
|
|
4dd23f1be8 | ||
|
|
0ebc988a68 | ||
|
|
9b8af84393 | ||
|
|
ff1ccd7c78 | ||
|
|
3176cc661a | ||
|
|
9ba387f2e4 | ||
|
|
c87dffd6da | ||
|
|
0cf69f5a59 | ||
|
|
babab1e09e | ||
|
|
6f5b079f51 | ||
|
|
9908669be0 | ||
|
|
c2f3e66405 | ||
|
|
b24c4668ed | ||
|
|
fcca387d9a | ||
|
|
97cc6a0d21 | ||
|
|
737565344d | ||
|
|
72f42afb81 | ||
|
|
0a2b91c9ac | ||
|
|
83b8fc597a | ||
|
|
0d4f2946f3 | ||
|
|
305efbea5d | ||
|
|
23f077ce75 | ||
|
|
d667c3c604 | ||
|
|
0502f52ec0 | ||
|
|
40f50bf37a | ||
|
|
0e0a46741f | ||
|
|
5b784659af | ||
|
|
e2f24eef8e | ||
|
|
aa43770bf4 | ||
|
|
45bc823de0 | ||
|
|
1250468f69 | ||
|
|
e94ce3b1cc | ||
|
|
ebb89facbd | ||
|
|
648b089c48 | ||
|
|
0befb6d431 | ||
|
|
35f2ad604c | ||
|
|
e139aee2b3 | ||
|
|
b57bea6f7b | ||
|
|
1828d2e710 | ||
|
|
04d929aae9 | ||
|
|
b51c36645e | ||
|
|
bd1ea5042e | ||
|
|
af4c66bc79 | ||
|
|
2d1f820451 | ||
|
|
179add9e12 | ||
|
|
9d3264256a | ||
|
|
fb234ed339 | ||
|
|
bb7724ece1 | ||
|
|
c67a7823a6 | ||
|
|
518109e9df | ||
|
|
e38a045de3 | ||
|
|
ba82d707d0 | ||
|
|
f366dd8cf2 | ||
|
|
dc6f02a000 | ||
|
|
b81bdebd64 | ||
|
|
6127d80f2a | ||
|
|
49c8a8c6d0 | ||
|
|
e2e0c35008 | ||
|
|
1de6eda49f | ||
|
|
000a0893c3 | ||
|
|
0a68ab682d | ||
|
|
54e51768c0 | ||
|
|
4eb294d856 | ||
|
|
e3b8f2cffe | ||
|
|
c158904efc | ||
|
|
f250082fff | ||
|
|
67432d3fdf | ||
|
|
0ff4299061 | ||
|
|
8ceb89053f | ||
|
|
6fbcb7cef5 | ||
|
|
f8d362352d | ||
|
|
ce3d073abd | ||
|
|
0e8b92e53d | ||
|
|
27d4dfcdfd | ||
|
|
38096db2dd | ||
|
|
bbb093b171 | ||
|
|
98bdf92d70 | ||
|
|
e572d7a626 | ||
|
|
aff4e3523c | ||
|
|
9972c5e40a | ||
|
|
2915ba2933 | ||
|
|
3d9264dae4 | ||
|
|
d030dbcfde | ||
|
|
60cede383a | ||
|
|
7ef06e8d05 | ||
|
|
e8475dbd8d | ||
|
|
3353d9f622 | ||
|
|
893631eb4c | ||
|
|
2286708d56 | ||
|
|
553cff37a1 | ||
|
|
7806c07381 | ||
|
|
b7a40ac3d7 | ||
|
|
5280209075 | ||
|
|
e0ebe92361 | ||
|
|
5c3966a9d6 | ||
|
|
38ca7b246b | ||
|
|
d9f2b21812 | ||
|
|
fb9f41248f | ||
|
|
4087fdd79e | ||
|
|
6bb2c2143e | ||
|
|
dae01698ef | ||
|
|
b65e844824 | ||
|
|
c64c506c52 | ||
|
|
889186ec3e | ||
|
|
9b3c89785e | ||
|
|
cfce4ba460 | ||
|
|
3cb72d89e9 | ||
|
|
cb6fb10c3c | ||
|
|
0c5f052f86 | ||
|
|
c36dc537ef | ||
|
|
4af64c8524 | ||
|
|
767e91f720 | ||
|
|
38447af730 | ||
|
|
94fb4dceac | ||
|
|
cbb98481c8 | ||
|
|
538806678d | ||
|
|
65cfe1a07a | ||
|
|
81ea0256c5 | ||
|
|
bd51342fdf | ||
|
|
e62ec45e82 | ||
|
|
31bcc21c35 | ||
|
|
2a128af227 | ||
|
|
9df339e500 | ||
|
|
09e4d4d452 | ||
|
|
74d8d516b3 | ||
|
|
44027b9303 | ||
|
|
2362d2365d | ||
|
|
155ff42958 | ||
|
|
f89260bacd | ||
|
|
93770d481a | ||
|
|
4a8a15e4d6 | ||
|
|
7a8707e5d0 | ||
|
|
e89bbb05b1 | ||
|
|
b9b868d55a | ||
|
|
50217d169d | ||
|
|
179a69df1c | ||
|
|
9e7f70c455 | ||
|
|
e4c21e8552 | ||
|
|
6a761c05e6 | ||
|
|
d9815cc96c | ||
|
|
0e14099f0c | ||
|
|
629ef72954 | ||
|
|
711acd6bb8 | ||
|
|
4cbada21a7 | ||
|
|
e04d071ca7 | ||
|
|
1568844255 | ||
|
|
89989fa102 | ||
|
|
bf94277b0f | ||
|
|
01cb37e82e | ||
|
|
9375960745 | ||
|
|
d8cb2cbbf6 | ||
|
|
82ec2664f3 | ||
|
|
9372db6279 | ||
|
|
e76c4a5902 | ||
|
|
075b54883b | ||
|
|
99861266c6 | ||
|
|
006f69e0d2 | ||
|
|
de4d62e63e | ||
|
|
dd272bf194 | ||
|
|
388ca462a4 | ||
|
|
5b85868993 | ||
|
|
f70fa75e86 | ||
|
|
bbfd3e5171 | ||
|
|
b1422bc97e | ||
|
|
f14f6ff536 | ||
|
|
c8657022a2 | ||
|
|
7b5ee7b0ed | ||
|
|
bda52d5f3d | ||
|
|
137f0ed7f3 | ||
|
|
cf839c9491 | ||
|
|
0d12487c65 | ||
|
|
dc20befb86 | ||
|
|
6c6b38a2e3 | ||
|
|
1ca706744e | ||
|
|
5e6fc4a82b | ||
|
|
7cbc9e0bb1 | ||
|
|
1ae8a8675e | ||
|
|
d3f5e613ea | ||
|
|
2479bae12e | ||
|
|
fd62b6ec67 | ||
|
|
348555981b | ||
|
|
6faf2e172b | ||
|
|
54953ccb4b | ||
|
|
f84773f1f8 | ||
|
|
603da5560f | ||
|
|
10f5bfef67 | ||
|
|
4613e91a13 | ||
|
|
937b65ae95 | ||
|
|
39ce73284e | ||
|
|
64d75794d3 | ||
|
|
59f59311b4 | ||
|
|
2c02712b1b | ||
|
|
8239bd3fbd | ||
|
|
29c0393f98 | ||
|
|
14aa60891c | ||
|
|
0c0a673fa9 | ||
|
|
6ca0dc7dfc | ||
|
|
91ee1e5c8b | ||
|
|
94f98d8e44 | ||
|
|
8c44be5122 | ||
|
|
2e7729ce84 | ||
|
|
6c39e1a2ab | ||
|
|
a9caac47d7 | ||
|
|
381a09d87e | ||
|
|
08e28b0a5f |
@@ -2,6 +2,7 @@
|
|||||||
name = "cz_conventional_commits"
|
name = "cz_conventional_commits"
|
||||||
tag_format = "v$version"
|
tag_format = "v$version"
|
||||||
version_scheme = "semver"
|
version_scheme = "semver"
|
||||||
version = "0.5.14"
|
version = "0.5.27"
|
||||||
update_changelog_on_bump = true
|
update_changelog_on_bump = true
|
||||||
major_version_zero = true
|
major_version_zero = true
|
||||||
|
changelog_file = "./docs/docs/changelog/index.md"
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ WORKDIR /code
|
|||||||
USER root:root
|
USER root:root
|
||||||
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
|
RUN mkdir -p /code && chown ${DEVBOX_USER}:${DEVBOX_USER} /code
|
||||||
USER ${DEVBOX_USER}:${DEVBOX_USER}
|
USER ${DEVBOX_USER}:${DEVBOX_USER}
|
||||||
|
|
||||||
|
# Copy devbox configuration files
|
||||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.json devbox.json
|
||||||
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
|
COPY --chown=${DEVBOX_USER}:${DEVBOX_USER} devbox.lock devbox.lock
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RUN devbox run -- echo "Installed Packages."
|
RUN devbox run -- echo "Installed Packages."
|
||||||
|
|
||||||
RUN devbox shellenv --init-hook >> ~/.profile
|
RUN devbox shellenv --init-hook >> ~/.profile
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,6 @@
|
|||||||
"dockerfile": "./Dockerfile",
|
"dockerfile": "./Dockerfile",
|
||||||
"context": ".."
|
"context": ".."
|
||||||
},
|
},
|
||||||
"features": {
|
|
||||||
"ghcr.io/devcontainers/features/sshd:1": {
|
|
||||||
"version": "latest"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"customizations": {
|
"customizations": {
|
||||||
"vscode": {
|
"vscode": {
|
||||||
"settings": {},
|
"settings": {},
|
||||||
@@ -17,5 +12,78 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"remoteUser": "devbox"
|
"remoteUser": "devbox",
|
||||||
|
"forwardPorts": [
|
||||||
|
1317,
|
||||||
|
26657,
|
||||||
|
9090,
|
||||||
|
3000,
|
||||||
|
80,
|
||||||
|
5000
|
||||||
|
],
|
||||||
|
"portsAttributes": {
|
||||||
|
"1317": {
|
||||||
|
"label": "sonr-api",
|
||||||
|
"onAutoForward": "notify"
|
||||||
|
},
|
||||||
|
"26657": {
|
||||||
|
"label": "sonr-rpc",
|
||||||
|
"onAutoForward": "notify"
|
||||||
|
},
|
||||||
|
"9090": {
|
||||||
|
"label": "sonr-grpc",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
},
|
||||||
|
"3000": {
|
||||||
|
"label": "hway-frontend",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
},
|
||||||
|
"80": {
|
||||||
|
"label": "ipfs-gateway",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
},
|
||||||
|
"5000": {
|
||||||
|
"label": "ipfs-api",
|
||||||
|
"onAutoForward": "silent"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"ghcr.io/michidk/devcontainers-features/bun:1": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/cirolosapio/devcontainers-features/alpine-ohmyzsh:0": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/guiyomh/features/golangci-lint:0": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/meaningful-ooo/devcontainer-features/homebrew:2": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/devcontainers/features/docker-in-docker:2": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/devcontainers/features/github-cli:1": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/devcontainers/features/go:1": {
|
||||||
|
"version": "latest",
|
||||||
|
"go": "1.23"
|
||||||
|
},
|
||||||
|
"ghcr.io/devcontainers/features/rust:1": {
|
||||||
|
"version": "latest",
|
||||||
|
"rust": "1.73"
|
||||||
|
},
|
||||||
|
"ghcr.io/jpawlowski/devcontainer-features/codespaces-dotfiles:1": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/duduribeiro/devcontainer-features/neovim:1": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/dlouwers/devcontainer-features/devbox:1": {
|
||||||
|
"version": "latest"
|
||||||
|
},
|
||||||
|
"ghcr.io/devcontainers/features/sshd:1": {
|
||||||
|
"version": "latest"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
You are an expert in Cosmos SDK data modeling and state management, specializing in building efficient and scalable data models using the Cosmos SDK ORM system with Protocol Buffers.
|
||||||
|
|
||||||
|
Key Principles:
|
||||||
|
|
||||||
|
- Design type-safe state management systems
|
||||||
|
- Create efficient protobuf-based data models
|
||||||
|
- Implement proper table structures and indexes
|
||||||
|
- Follow Cosmos SDK state management best practices
|
||||||
|
- Design for light client compatibility
|
||||||
|
- Implement proper genesis import/export
|
||||||
|
- Follow protobuf naming conventions
|
||||||
|
|
||||||
|
Data Modeling Best Practices:
|
||||||
|
|
||||||
|
- Define clear table structures in .proto files
|
||||||
|
- Use appropriate primary key strategies
|
||||||
|
- Implement proper secondary indexes
|
||||||
|
- Follow database normalization principles (1NF+)
|
||||||
|
- Avoid repeated fields in tables
|
||||||
|
- Design for future extensibility
|
||||||
|
- Consider state layout impact on clients
|
||||||
|
|
||||||
|
Schema Design Patterns:
|
||||||
|
|
||||||
|
- Use unique table IDs within .proto files
|
||||||
|
- Implement proper field numbering
|
||||||
|
- Design efficient multipart keys
|
||||||
|
- Use appropriate field types
|
||||||
|
- Consider index performance implications
|
||||||
|
- Implement proper singleton patterns
|
||||||
|
- Design for automatic query services
|
||||||
|
|
||||||
|
State Management:
|
||||||
|
|
||||||
|
- Follow Cosmos SDK store patterns
|
||||||
|
- Implement proper prefix handling
|
||||||
|
- Design efficient range queries
|
||||||
|
- Use appropriate encoding strategies
|
||||||
|
- Handle state migrations properly
|
||||||
|
- Implement proper genesis handling
|
||||||
|
- Consider light client proof requirements
|
||||||
|
|
||||||
|
Error Handling and Validation:
|
||||||
|
|
||||||
|
- Implement proper input validation
|
||||||
|
- Use appropriate error types
|
||||||
|
- Handle state errors appropriately
|
||||||
|
- Implement proper debugging
|
||||||
|
- Use context appropriately
|
||||||
|
- Implement proper logging
|
||||||
|
- Handle concurrent access
|
||||||
|
|
||||||
|
Performance Optimization:
|
||||||
|
|
||||||
|
- Design efficient key encodings
|
||||||
|
- Optimize storage space usage
|
||||||
|
- Implement efficient queries
|
||||||
|
- Use appropriate index strategies
|
||||||
|
- Consider state growth implications
|
||||||
|
- Monitor performance metrics
|
||||||
|
- Design for scalability
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
|
||||||
|
- cosmos/orm/v1/orm.proto
|
||||||
|
- [google.golang.org/protobuf](http://google.golang.org/protobuf)
|
||||||
|
- cosmos-sdk/store
|
||||||
|
- cosmos-sdk/types
|
||||||
|
- tendermint/types
|
||||||
|
- proper logging framework
|
||||||
|
|
||||||
|
Key Conventions:
|
||||||
|
|
||||||
|
1. Use consistent protobuf naming
|
||||||
|
2. Implement proper documentation
|
||||||
|
3. Follow schema versioning practices
|
||||||
|
4. Use proper table ID management
|
||||||
|
5. Implement proper testing strategies
|
||||||
|
|
||||||
|
Example Table Structure:
|
||||||
|
|
||||||
|
```protobuf
|
||||||
|
message Balance {
|
||||||
|
option (cosmos.orm.v1.table) = {
|
||||||
|
id: 1
|
||||||
|
primary_key: { fields: "account,denom" }
|
||||||
|
index: { id: 1, fields: "denom" }
|
||||||
|
};
|
||||||
|
|
||||||
|
bytes account = 1;
|
||||||
|
string denom = 2;
|
||||||
|
uint64 amount = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Params {
|
||||||
|
option (cosmos.orm.v1.singleton) = {
|
||||||
|
id: 2
|
||||||
|
};
|
||||||
|
|
||||||
|
google.protobuf.Duration voting_period = 1;
|
||||||
|
uint64 min_threshold = 2;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Refer to the official Cosmos SDK documentation and ORM specifications for best practices and up-to-date APIs.
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
You are an expert in Go data modeling and PostgreSQL database design, specializing in building efficient and scalable data models using modern ORMs like GORM and SQLBoiler.
|
||||||
|
|
||||||
|
Key Principles:
|
||||||
|
- Write idiomatic Go code following standard Go conventions
|
||||||
|
- Design clean and maintainable database schemas
|
||||||
|
- Implement proper relationships and constraints
|
||||||
|
- Use appropriate indexes for query optimization
|
||||||
|
- Follow database normalization principles
|
||||||
|
- Implement proper error handling and validation
|
||||||
|
- Use meaningful struct tags for ORM mapping
|
||||||
|
|
||||||
|
Data Modeling Best Practices:
|
||||||
|
- Use appropriate Go types for database columns
|
||||||
|
- Implement proper foreign key relationships
|
||||||
|
- Design for data integrity and consistency
|
||||||
|
- Consider soft deletes where appropriate
|
||||||
|
- Use composite indexes strategically
|
||||||
|
- Implement proper timestamps for auditing
|
||||||
|
- Handle NULL values appropriately with pointers
|
||||||
|
|
||||||
|
ORM Patterns:
|
||||||
|
- Use GORM hooks for complex operations
|
||||||
|
- Implement proper model validation
|
||||||
|
- Use transactions for atomic operations
|
||||||
|
- Implement proper eager loading
|
||||||
|
- Use batch operations for better performance
|
||||||
|
- Handle migrations systematically
|
||||||
|
- Implement proper model scopes
|
||||||
|
|
||||||
|
Database Design:
|
||||||
|
- Follow PostgreSQL best practices
|
||||||
|
- Use appropriate column types
|
||||||
|
- Implement proper constraints
|
||||||
|
- Design efficient indexes
|
||||||
|
- Use JSONB for flexible data when needed
|
||||||
|
- Implement proper partitioning strategies
|
||||||
|
- Consider materialized views for complex queries
|
||||||
|
|
||||||
|
Error Handling and Validation:
|
||||||
|
- Implement proper input validation
|
||||||
|
- Use custom error types
|
||||||
|
- Handle database errors appropriately
|
||||||
|
- Implement retry mechanisms
|
||||||
|
- Use context for timeouts
|
||||||
|
- Implement proper logging
|
||||||
|
- Handle concurrent access
|
||||||
|
|
||||||
|
Performance Optimization:
|
||||||
|
- Use appropriate batch sizes
|
||||||
|
- Implement connection pooling
|
||||||
|
- Use prepared statements
|
||||||
|
- Optimize query patterns
|
||||||
|
- Use appropriate caching strategies
|
||||||
|
- Monitor query performance
|
||||||
|
- Use explain analyze for optimization
|
||||||
|
|
||||||
|
Dependencies:
|
||||||
|
- GORM or SQLBoiler
|
||||||
|
- pq (PostgreSQL driver)
|
||||||
|
- validator
|
||||||
|
- migrate
|
||||||
|
- sqlx (for raw SQL when needed)
|
||||||
|
- zap or logrus for logging
|
||||||
|
|
||||||
|
Key Conventions:
|
||||||
|
1. Use consistent naming conventions
|
||||||
|
2. Implement proper documentation
|
||||||
|
3. Follow database migration best practices
|
||||||
|
4. Use version control for schema changes
|
||||||
|
5. Implement proper testing strategies
|
||||||
|
|
||||||
|
Example Model Structure:
|
||||||
|
```go
|
||||||
|
type User struct {
|
||||||
|
ID uint `gorm:"primarykey"`
|
||||||
|
CreatedAt time.Time
|
||||||
|
UpdatedAt time.Time
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
|
|
||||||
|
Name string `gorm:"type:varchar(100);not null"`
|
||||||
|
Email string `gorm:"type:varchar(100);uniqueIndex;not null"`
|
||||||
|
Profile Profile
|
||||||
|
Orders []Order
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Refer to the official documentation of GORM, PostgreSQL, and Go for best practices and up-to-date APIs.
|
||||||
|
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
You are a technical lead specializing in decentralized identity systems and security architecture, with expertise in W3C standards, Cosmos SDK, and blockchain security patterns.
|
||||||
|
|
||||||
|
Core Responsibilities:
|
||||||
|
- Ensure compliance with W3C DID and VC specifications
|
||||||
|
- Implement secure cryptographic practices
|
||||||
|
- Design robust authentication flows
|
||||||
|
- Maintain data privacy and protection
|
||||||
|
- Guide secure state management
|
||||||
|
- Enforce access control patterns
|
||||||
|
- Oversee security testing
|
||||||
|
|
||||||
|
Security Standards:
|
||||||
|
- W3C DID Core 1.0
|
||||||
|
- W3C Verifiable Credentials
|
||||||
|
- W3C WebAuthn Level 2
|
||||||
|
- OAuth 2.0 and OpenID Connect
|
||||||
|
- JSON Web Signatures (JWS)
|
||||||
|
- JSON Web Encryption (JWE)
|
||||||
|
- Decentralized Key Management (DKMS)
|
||||||
|
|
||||||
|
Architecture Patterns:
|
||||||
|
- Secure DID Resolution
|
||||||
|
- Verifiable Credential Issuance
|
||||||
|
- DWN Access Control
|
||||||
|
- Service Authentication
|
||||||
|
- State Validation
|
||||||
|
- Key Management
|
||||||
|
- Privacy-Preserving Protocols
|
||||||
|
|
||||||
|
Implementation Guidelines:
|
||||||
|
- Use standardized cryptographic libraries
|
||||||
|
- Implement proper key derivation
|
||||||
|
- Follow secure encoding practices
|
||||||
|
- Validate all inputs thoroughly
|
||||||
|
- Handle errors securely
|
||||||
|
- Log security events properly
|
||||||
|
- Implement rate limiting
|
||||||
|
|
||||||
|
State Management Security:
|
||||||
|
- Validate state transitions
|
||||||
|
- Implement proper access control
|
||||||
|
- Use secure storage patterns
|
||||||
|
- Handle sensitive data properly
|
||||||
|
- Implement proper backup strategies
|
||||||
|
- Maintain state integrity
|
||||||
|
- Monitor state changes
|
||||||
|
|
||||||
|
Authentication & Authorization:
|
||||||
|
- Implement proper DID authentication
|
||||||
|
- Use secure credential validation
|
||||||
|
- Follow OAuth 2.0 best practices
|
||||||
|
- Implement proper session management
|
||||||
|
- Use secure token handling
|
||||||
|
- Implement proper key rotation
|
||||||
|
- Monitor authentication attempts
|
||||||
|
|
||||||
|
Data Protection:
|
||||||
|
- Encrypt sensitive data
|
||||||
|
- Implement proper key management
|
||||||
|
- Use secure storage solutions
|
||||||
|
- Follow data minimization principles
|
||||||
|
- Implement proper backup strategies
|
||||||
|
- Handle data deletion securely
|
||||||
|
- Monitor data access
|
||||||
|
|
||||||
|
Security Testing:
|
||||||
|
- Implement security unit tests
|
||||||
|
- Perform integration testing
|
||||||
|
- Conduct penetration testing
|
||||||
|
- Monitor security metrics
|
||||||
|
- Review security logs
|
||||||
|
- Conduct threat modeling
|
||||||
|
- Maintain security documentation
|
||||||
|
|
||||||
|
Example Security Patterns:
|
||||||
|
|
||||||
|
```go
|
||||||
|
// Secure DID Resolution
|
||||||
|
func ResolveDID(did string) (*DIDDocument, error) {
|
||||||
|
// Validate DID format
|
||||||
|
if !ValidateDIDFormat(did) {
|
||||||
|
return nil, ErrInvalidDID
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resolve with retry and timeout
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), resolveTimeout)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
doc, err := resolver.ResolveWithContext(ctx, did)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("resolution failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate document structure
|
||||||
|
if err := ValidateDIDDocument(doc); err != nil {
|
||||||
|
return nil, fmt.Errorf("invalid document: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Secure Credential Verification
|
||||||
|
func VerifyCredential(vc *VerifiableCredential) error {
|
||||||
|
// Check expiration
|
||||||
|
if vc.IsExpired() {
|
||||||
|
return ErrCredentialExpired
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify proof
|
||||||
|
if err := vc.VerifyProof(trustRegistry); err != nil {
|
||||||
|
return fmt.Errorf("invalid proof: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify status
|
||||||
|
if err := vc.CheckRevocationStatus(); err != nil {
|
||||||
|
return fmt.Errorf("revocation check failed: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Security Checklist:
|
||||||
|
1. All DIDs follow W3C specification
|
||||||
|
2. Credentials implement proper proofs
|
||||||
|
3. Keys use proper derivation/rotation
|
||||||
|
4. State changes are validated
|
||||||
|
5. Access control is enforced
|
||||||
|
6. Data is properly encrypted
|
||||||
|
7. Logging captures security events
|
||||||
|
|
||||||
|
Refer to W3C specifications, Cosmos SDK security documentation, and blockchain security best practices for detailed implementation guidance.
|
||||||
@@ -0,0 +1,427 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "app/cosmos-sdk",
|
||||||
|
"path": "app",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"module",
|
||||||
|
"cosmos"
|
||||||
|
],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/module-manager"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"protobuf",
|
||||||
|
"cosmos"
|
||||||
|
],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/messages-and-queries"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"rpc",
|
||||||
|
"protobuf",
|
||||||
|
"service",
|
||||||
|
"cosmos"
|
||||||
|
],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/msg-services"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"protobuf",
|
||||||
|
"rpc",
|
||||||
|
"cosmos",
|
||||||
|
"query"
|
||||||
|
],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/query-services"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"cosmos",
|
||||||
|
"depinject",
|
||||||
|
"sdk"
|
||||||
|
],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/depinject"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "app/ibc",
|
||||||
|
"path": "app",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"cosmos",
|
||||||
|
"interchain",
|
||||||
|
"accounts"
|
||||||
|
],
|
||||||
|
"url": "https://ibc.cosmos.network/v8/apps/interchain-accounts/overview/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://ibc.cosmos.network/v8/apps/transfer/overview/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.osmosis.zone/osmosis-core/asset-info/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.osmosis.zone/osmosis-core/modules/tokenfactory"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"usdc",
|
||||||
|
"mint",
|
||||||
|
"cosmos",
|
||||||
|
"noble"
|
||||||
|
],
|
||||||
|
"url": "https://docs.noble.xyz/cctp/mint"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"usdc"
|
||||||
|
],
|
||||||
|
"url": "https://docs.noble.xyz/cctp/mint_forward"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.evmos.org/protocol/modules/erc20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.nomic.io/nbtc"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "crypto/mpc",
|
||||||
|
"path": "crypto/mpc",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"mpc",
|
||||||
|
"wallet",
|
||||||
|
"security",
|
||||||
|
"advanced cryptography"
|
||||||
|
],
|
||||||
|
"url": "https://csrc.nist.gov/CSRC/media/Events/NTCW19/papers/paper-DKLS.pdf"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "crypto/ucan",
|
||||||
|
"path": "crypto/ucan",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://raw.githubusercontent.com/ucan-wg/spec/refs/heads/main/README.md"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "crypto/zkp",
|
||||||
|
"path": "crypto/accumulator",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://eprint.iacr.org/2021/1672.pdf"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gateway/handlers",
|
||||||
|
"path": "pkg/gateway/handlers",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://echo.labstack.com/docs/cookbook/sse"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://echo.labstack.com/docs/cookbook/websocket"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://echo.labstack.com/docs/cookbook/subdomain"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "gateway/database",
|
||||||
|
"path": "pkg/gateway/internal/database",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.tigerbeetle.com/coding/data-modeling"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.tigerbeetle.com/coding/two-phase-transfers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.tigerbeetle.com/coding/reliable-transaction-submission"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"currency"
|
||||||
|
],
|
||||||
|
"url": "https://docs.tigerbeetle.com/coding/recipes/currency-exchange"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [
|
||||||
|
"balance"
|
||||||
|
],
|
||||||
|
"url": "https://docs.tigerbeetle.com/coding/recipes/balance-conditional-transfers"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.tigerbeetle.com/reference/account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.tigerbeetle.com/reference/transfer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.substreams.dev/documentation/consume/packages"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.substreams.dev/documentation/consume/sql/deployable-services/local-service"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.substreams.dev/tutorials/cosmos/injective/foundational"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vault/handlers",
|
||||||
|
"path": "pkg/vault/handlers",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://echo.labstack.com/docs/cookbook/jwt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://echo.labstack.com/docs/middleware/secure"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vault/database",
|
||||||
|
"path": "pkg/vault/internal/database",
|
||||||
|
"docs": [
|
||||||
|
"https://dexie.org/docs/ExportImport/dexie-export-import",
|
||||||
|
"https://dexie.org/docs/API-Reference#quick-reference",
|
||||||
|
"https://templ.guide/syntax-and-usage/script-templates"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pkl/ipfs",
|
||||||
|
"path": "pkl/ipfs.net",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://github.com/ipfs/kubo/blob/master/docs/config.md"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pkl/matrix",
|
||||||
|
"path": "pkl/matrix.net",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pkl/chain",
|
||||||
|
"path": "pkl/sonr.chain",
|
||||||
|
"docs": [
|
||||||
|
"https://tutorials.cosmos.network/tutorials/9-path-to-prod/5-network.html",
|
||||||
|
"https://tutorials.cosmos.network/tutorials/9-path-to-prod/4-genesis.html",
|
||||||
|
"https://pkl-lang.org/main/current/language-reference/index.html",
|
||||||
|
"https://docs.cosmos.network/v0.50/user/run-node/run-testnet"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pkl/hway",
|
||||||
|
"path": "pkl/sonr.hway",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "pkl/motr",
|
||||||
|
"path": "pkl/sonr.motr",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://pkl-lang.org/main/current/language-reference/index.html"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://web.dev/learn/pwa/service-workers/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x/did",
|
||||||
|
"path": "proto/did",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/packages/orm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/protobuf-annotations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/auth"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/packages/collections"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/bank"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x/dwn",
|
||||||
|
"path": "proto/dwn",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/protobuf-annotations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/packages/orm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/authz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/packages/collections"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/gov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/staking"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "x/svc",
|
||||||
|
"path": "proto/svc",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/packages/collections"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/building-modules/protobuf-annotations"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/packages/orm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/group"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/modules/nft"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "repo/ci-cd",
|
||||||
|
"path": "deploy",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.cosmos.network/v0.50/build/tooling/cosmovisor"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://f1bonacc1.github.io/process-compose/configuration/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://docs.nomic.io/network/ibc-relayer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://www.jetify.com/docs/devbox"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://taskfile.dev/reference/cli"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://taskfile.dev/reference/schema"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://taskfile.dev/reference/templating/"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "repo/docs",
|
||||||
|
"path": "docs",
|
||||||
|
"docs": [
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://squidfunk.github.io/mkdocs-material/reference/"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keywords": [],
|
||||||
|
"url": "https://github.com/mkdocs/catalog/blob/main/README.md"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
Executable
+63
@@ -0,0 +1,63 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ROOT_DIR=$(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
# Extract scope name and path using jq, and pass it to fzf for selection
|
||||||
|
SCOPE=$(cat "$ROOT_DIR/.github/scopes.json" | jq -r '.[] | "\(.name)"' | fzf --prompt "Select scope:")
|
||||||
|
DOCS=$(cat "$ROOT_DIR/.github/scopes.json" | jq -r ".[] | select(.name == \"$SCOPE\") | .docs[].url")
|
||||||
|
|
||||||
|
# Write Title
|
||||||
|
TITLE=$(gum input --placeholder "Issue Title...")
|
||||||
|
|
||||||
|
# Write Goal
|
||||||
|
GOAL=$(mods --role "determine-issue-goal" "$SCOPE $TITLE")
|
||||||
|
|
||||||
|
# Input Requirements
|
||||||
|
REQUIREMENTS=()
|
||||||
|
while true; do
|
||||||
|
if [ ${#REQUIREMENTS[@]} -ge 2 ]; then
|
||||||
|
if ! gum confirm "Do you want to add another requirement?"; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
REQUIREMENT=$(gum input --placeholder "Add a requirement...")
|
||||||
|
if [ -n "$REQUIREMENT" ]; then
|
||||||
|
REQUIREMENTS+=("$REQUIREMENT")
|
||||||
|
else
|
||||||
|
echo "Requirement cannot be empty. Please enter a valid requirement."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
create_body() {
|
||||||
|
echo "### Goal(s):"
|
||||||
|
echo "$GOAL"
|
||||||
|
echo "### Requirements:"
|
||||||
|
for i in "${!REQUIREMENTS[@]}"; do
|
||||||
|
echo "$(($i + 1)). ${REQUIREMENTS[$i]}"
|
||||||
|
done
|
||||||
|
echo "### Resources:"
|
||||||
|
while IFS= read -r doc; do
|
||||||
|
echo "- $doc"
|
||||||
|
done <<< "$DOCS"
|
||||||
|
}
|
||||||
|
|
||||||
|
ISSUE_BODY=$(create_body)
|
||||||
|
|
||||||
|
# Function to collect output
|
||||||
|
preview_output() {
|
||||||
|
echo "# ($SCOPE) $TITLE"
|
||||||
|
echo "$ISSUE_BODY"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display the formatted output
|
||||||
|
preview_output | gum format
|
||||||
|
|
||||||
|
# Confirm to create a GitHub issue
|
||||||
|
if gum confirm "Do you want to create a new GitHub issue with this information?"; then
|
||||||
|
# Create a new GitHub issue using the gh CLI
|
||||||
|
gh issue create --repo onsonr/sonr --title "($SCOPE) $TITLE" --body "$ISSUE_BODY"
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Executable
+39
@@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ROOT_DIR=$(git rev-parse --show-toplevel)
|
||||||
|
|
||||||
|
# Package the PKL projects
|
||||||
|
bunx pkl project package $ROOT_DIR/pkl/*/
|
||||||
|
|
||||||
|
# Process each directory in .out
|
||||||
|
for dir in .out/*/; do
|
||||||
|
# Get the folder name and version
|
||||||
|
folder=$(basename "$dir")
|
||||||
|
version=$(echo "$folder" | grep -o '@.*' | sed 's/@//')
|
||||||
|
new_folder=$(echo "$folder" | sed 's/@[0-9.]*$//')
|
||||||
|
|
||||||
|
# Create new directory without version
|
||||||
|
mkdir -p ".out/$new_folder/$version"
|
||||||
|
|
||||||
|
# Copy contents to versioned subdirectory
|
||||||
|
cp -r "$dir"* ".out/$new_folder/$version/"
|
||||||
|
|
||||||
|
# Find and copy only .pkl files from the original package
|
||||||
|
pkg_dir="$ROOT_DIR/pkl/$new_folder"
|
||||||
|
if [ -d "$pkg_dir" ]; then
|
||||||
|
# Copy only .pkl files to version directory
|
||||||
|
find "$pkg_dir" -name "*.pkl" -exec cp {} ".out/$new_folder/$version/" \;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove old versioned directory
|
||||||
|
rm -rf "$dir"
|
||||||
|
|
||||||
|
# Upload to R2 with new structure
|
||||||
|
rclone copy ".out/$new_folder" "r2:pkljar/$new_folder"
|
||||||
|
done
|
||||||
|
|
||||||
|
# Cleanup .out directory
|
||||||
|
rm -rf .out
|
||||||
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
name: Run All Checks
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
merge_group:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test-builds:
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Run Build Tests
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- name: Run Sonrd Build
|
||||||
|
run: make build
|
||||||
|
- name: Run Hway Build
|
||||||
|
run: make build-hway
|
||||||
|
- name: Run Motr Build
|
||||||
|
run: make build-motr
|
||||||
|
|
||||||
|
test-unit:
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Run Unit Tests
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- run: make test-unit
|
||||||
|
|
||||||
|
test-race:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'merge_group'
|
||||||
|
name: Run Race Tests
|
||||||
|
continue-on-error: true
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- run: make test-race
|
||||||
|
|
||||||
|
test-cover:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name == 'merge_group'
|
||||||
|
name: Run Coverage Tests
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
- run: make test-cover
|
||||||
|
|
||||||
|
goreleaser-check:
|
||||||
|
if: github.event_name == 'merge_group'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Check GoReleaser Config
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
repository: onsonr/sonr
|
||||||
|
fetch-depth: 0
|
||||||
|
fetch-tags: true
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: "1.23"
|
||||||
|
check-latest: true
|
||||||
|
|
||||||
|
- name: Check GoReleaser Config
|
||||||
|
uses: goreleaser/goreleaser-action@v6
|
||||||
|
with:
|
||||||
|
distribution: goreleaser-pro
|
||||||
|
version: latest
|
||||||
|
args: check
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
|
|
||||||
|
- name: GoReleaser Dry Run
|
||||||
|
uses: goreleaser/goreleaser-action@v6
|
||||||
|
with:
|
||||||
|
distribution: goreleaser-pro
|
||||||
|
version: latest
|
||||||
|
args: release --snapshot --clean --skip=publish
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
name: Deploy Networks
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
branches:
|
||||||
|
- develop
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
issues: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
reboot-devnet:
|
||||||
|
name: Devnet Deploy
|
||||||
|
runs-on: goliath
|
||||||
|
environment: "Devnet"
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
branch: develop
|
||||||
|
|
||||||
|
- name: Stop Existing Network
|
||||||
|
continue-on-error: true
|
||||||
|
run: |
|
||||||
|
make stop-uds
|
||||||
|
make clean
|
||||||
|
|
||||||
|
- name: Start Updated Network
|
||||||
|
run: |
|
||||||
|
make start-uds
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
name: PR Labeler
|
name: PR Labeler
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened]
|
types: [opened, edited]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
name: Publish Docs via GitHub Pages
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- master
|
||||||
|
- develop
|
||||||
|
paths:
|
||||||
|
- "docs/**"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Configure Git Credentials
|
||||||
|
run: |
|
||||||
|
git config user.name github-actions[bot]
|
||||||
|
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
|
||||||
|
- uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
key: mkdocs-material-${{ env.cache_id }}
|
||||||
|
path: .cache
|
||||||
|
restore-keys: |
|
||||||
|
mkdocs-material-
|
||||||
|
- run: pip install mkdocs-material
|
||||||
|
- run: cd docs && mkdocs gh-deploy --force
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Upload Public Assets
|
name: Publish Versioned Assets
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@@ -9,7 +9,7 @@ permissions:
|
|||||||
issues: write
|
issues: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
buf_push:
|
buf_push_core:
|
||||||
name: Publish to buf.build/onsonr/sonr
|
name: Publish to buf.build/onsonr/sonr
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -23,54 +23,3 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
input: proto
|
input: proto
|
||||||
buf_token: ${{ secrets.BUF_TOKEN }}
|
buf_token: ${{ secrets.BUF_TOKEN }}
|
||||||
|
|
||||||
#
|
|
||||||
# upload_configs:
|
|
||||||
# runs-on: ubuntu-latest
|
|
||||||
# name: Publish to configs.sonr.id
|
|
||||||
# steps:
|
|
||||||
# - name: checkout
|
|
||||||
# uses: actions/checkout@v4
|
|
||||||
# - name: Upload to R2
|
|
||||||
# continue-on-error: true
|
|
||||||
# uses: ryand56/r2-upload-action@latest
|
|
||||||
# with:
|
|
||||||
# r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
|
|
||||||
# r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
||||||
# r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
||||||
# r2-bucket: configs
|
|
||||||
# source-dir: config
|
|
||||||
# destination-dir: ./pkl
|
|
||||||
#
|
|
||||||
|
|
||||||
upload_pkl:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Publish to pkl.sh
|
|
||||||
steps:
|
|
||||||
- name: checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Upload to R2
|
|
||||||
uses: ryand56/r2-upload-action@latest
|
|
||||||
with:
|
|
||||||
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
|
|
||||||
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
||||||
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
||||||
r2-bucket: pkljar
|
|
||||||
source-dir: pkl
|
|
||||||
destination-dir: .
|
|
||||||
|
|
||||||
upload_nebula_cdn:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Publish to cdn.sonr.id
|
|
||||||
steps:
|
|
||||||
- name: checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Upload to R2
|
|
||||||
uses: ryand56/r2-upload-action@latest
|
|
||||||
with:
|
|
||||||
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }}
|
|
||||||
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }}
|
|
||||||
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }}
|
|
||||||
r2-bucket: nebula
|
|
||||||
source-dir: pkg/nebula/assets
|
|
||||||
destination-dir: .
|
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
name: Run Tests
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- feature/*
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-unit:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Run Unit Tests
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- run: make test-unit
|
|
||||||
|
|
||||||
test-race:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Run Race Tests
|
|
||||||
continue-on-error: true
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- run: make test-race
|
|
||||||
|
|
||||||
test-cover:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
name: Run Coverage Tests
|
|
||||||
continue-on-error: true
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
repository: onsonr/sonr
|
|
||||||
fetch-depth: 0
|
|
||||||
fetch-tags: true
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.23"
|
|
||||||
check-latest: true
|
|
||||||
- run: make test-cover
|
|
||||||
@@ -1,17 +1,51 @@
|
|||||||
name: Scheduled Release
|
name: Versioned Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- v*
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
||||||
|
workflow_dispatch:
|
||||||
|
repository_dispatch:
|
||||||
|
types: [trigger-release]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
check-release:
|
||||||
|
name: Check Existing Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
release_exists: ${{ steps.check.outputs.release_exists }}
|
||||||
|
is_tag: ${{ steps.check-ref.outputs.is_tag }}
|
||||||
|
ref_name: ${{ steps.check-ref.outputs.ref_name }}
|
||||||
|
steps:
|
||||||
|
- name: Determine ref type and name
|
||||||
|
id: check-ref
|
||||||
|
run: |
|
||||||
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||||
|
echo "is_tag=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "ref_name=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "is_tag=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "ref_name=${GITHUB_REF#refs/heads/}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Check if release exists
|
||||||
|
id: check
|
||||||
|
if: steps.check-ref.outputs.is_tag == 'true'
|
||||||
|
run: |
|
||||||
|
RELEASE_EXISTS=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
|
||||||
|
"https://api.github.com/repos/onsonr/sonr/releases/tags/${GITHUB_REF#refs/tags/}" \
|
||||||
|
| jq -r 'if .message == "Not Found" then "false" else "true" end')
|
||||||
|
echo "release_exists=$RELEASE_EXISTS" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
goreleaser:
|
goreleaser:
|
||||||
name: Release motr, sonrd, and DWN
|
name: Run GoReleaser
|
||||||
|
needs: check-release
|
||||||
|
if: |
|
||||||
|
(needs.check-release.outputs.is_tag == 'true' && needs.check-release.outputs.release_exists == 'false') ||
|
||||||
|
(needs.check-release.outputs.is_tag == 'false')
|
||||||
permissions: write-all
|
permissions: write-all
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
@@ -22,9 +56,21 @@ jobs:
|
|||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
fetch-tags: true
|
fetch-tags: true
|
||||||
|
|
||||||
|
- name: Set up release configuration
|
||||||
|
id: setup
|
||||||
|
run: |
|
||||||
|
if [[ "${{ needs.check-release.outputs.is_tag }}" == "true" ]]; then
|
||||||
|
echo "Using tag configuration"
|
||||||
|
git checkout ${{ needs.check-release.outputs.ref_name }}
|
||||||
|
echo "args=release --clean" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "Using snapshot configuration"
|
||||||
|
echo "args=release --snapshot --clean" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- uses: actions/setup-go@v5
|
- uses: actions/setup-go@v5
|
||||||
with:
|
with:
|
||||||
go-version: "1.22"
|
go-version: "1.23"
|
||||||
check-latest: true
|
check-latest: true
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
- name: Login to Docker Hub
|
||||||
@@ -38,7 +84,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
distribution: goreleaser-pro
|
distribution: goreleaser-pro
|
||||||
version: latest
|
version: latest
|
||||||
args: release --clean
|
args: ${{ steps.setup.outputs.args }}
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_RELEASER_TOKEN }}
|
||||||
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
|
||||||
@@ -46,3 +92,4 @@ jobs:
|
|||||||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
||||||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
|
||||||
|
CLOUDSMITH_TOKEN: ${{ secrets.CLOUDSMITH_TOKEN }}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
name: Update Version
|
name: Update Version and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -10,30 +10,33 @@ permissions:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run-tests:
|
|
||||||
name: "Run tests"
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: "1.22"
|
|
||||||
check-latest: true
|
|
||||||
- name: Run tests
|
|
||||||
run: make test
|
|
||||||
|
|
||||||
bump-version:
|
bump-version:
|
||||||
needs: [run-tests]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: "Bump Version"
|
name: "Bump Version"
|
||||||
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
|
if: ${{ !startsWith(github.event.head_commit.message, 'bump:') }}
|
||||||
|
outputs:
|
||||||
|
new_tag: ${{ steps.bump.outputs.new_tag }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Create bump and changelog
|
- name: Create bump and changelog
|
||||||
|
id: bump
|
||||||
uses: commitizen-tools/commitizen-action@master
|
uses: commitizen-tools/commitizen-action@master
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
increment: "PATCH"
|
increment: "PATCH"
|
||||||
|
|
||||||
|
trigger-release:
|
||||||
|
needs: [bump-version]
|
||||||
|
if: needs.bump-version.outputs.new_tag != ''
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Trigger release workflow
|
||||||
|
uses: peter-evans/repository-dispatch@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
event-type: trigger-release
|
||||||
|
client-payload: '{"tag": "${{ needs.bump-version.outputs.new_tag }}"}'
|
||||||
|
|||||||
+24
-2
@@ -1,5 +1,9 @@
|
|||||||
# Binaries
|
# Binaries
|
||||||
|
no
|
||||||
.data
|
.data
|
||||||
|
schemas
|
||||||
|
*.db
|
||||||
|
tools-stamp
|
||||||
*.exe
|
*.exe
|
||||||
*.exe~
|
*.exe~
|
||||||
*.dll
|
*.dll
|
||||||
@@ -10,14 +14,21 @@
|
|||||||
.session.vim
|
.session.vim
|
||||||
aof*
|
aof*
|
||||||
dist
|
dist
|
||||||
|
**/.haptic
|
||||||
|
static
|
||||||
|
pkg/webapp/dist
|
||||||
|
.agent
|
||||||
|
|
||||||
# Test binary
|
# Test binary
|
||||||
*.test
|
*.test
|
||||||
.devon*
|
.devon*
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
.task
|
||||||
|
.wrangler
|
||||||
|
|
||||||
# Output of the go coverage tool
|
# Output of the go coverage tool
|
||||||
*.out
|
*.out
|
||||||
|
tmp
|
||||||
# Exclude embedded files
|
# Exclude embedded files
|
||||||
!internal/files/dist
|
!internal/files/dist
|
||||||
|
|
||||||
@@ -31,6 +42,7 @@ go.work.sum
|
|||||||
# Environment files
|
# Environment files
|
||||||
.env
|
.env
|
||||||
**/*.env
|
**/*.env
|
||||||
|
**/sonr.log
|
||||||
|
|
||||||
|
|
||||||
# Terraform
|
# Terraform
|
||||||
@@ -50,6 +62,7 @@ override.tf.json
|
|||||||
.terraformrc
|
.terraformrc
|
||||||
terraform.rc
|
terraform.rc
|
||||||
|
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.tmp/
|
.tmp/
|
||||||
@@ -71,7 +84,9 @@ deploy/**/data
|
|||||||
x/.DS_Store
|
x/.DS_Store
|
||||||
.aider*
|
.aider*
|
||||||
buildenv*
|
buildenv*
|
||||||
nebula/node_modules
|
node_modules
|
||||||
|
cmd/gateway/node_modules
|
||||||
|
pkg/nebula/node_modules
|
||||||
|
|
||||||
mprocs.yaml
|
mprocs.yaml
|
||||||
build
|
build
|
||||||
@@ -79,3 +94,10 @@ sonr.wiki
|
|||||||
|
|
||||||
!devbox.lock
|
!devbox.lock
|
||||||
!buf.lock
|
!buf.lock
|
||||||
|
|
||||||
|
.air.toml
|
||||||
|
mprocs.yaml
|
||||||
|
mprocs.log
|
||||||
|
tools-stamp
|
||||||
|
sonr.log
|
||||||
|
|
||||||
|
|||||||
+143
-26
@@ -4,24 +4,161 @@ project_name: sonr
|
|||||||
|
|
||||||
builds:
|
builds:
|
||||||
- id: sonr
|
- id: sonr
|
||||||
goos: [linux, darwin]
|
|
||||||
goarch: [amd64, arm64]
|
|
||||||
main: ./cmd/sonrd
|
main: ./cmd/sonrd
|
||||||
binary: sonrd
|
binary: sonrd
|
||||||
builder: go
|
builder: go
|
||||||
gobinary: go
|
gobinary: go
|
||||||
command: build
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
goamd64:
|
||||||
|
- v1
|
||||||
|
flags:
|
||||||
|
- -mod=readonly
|
||||||
|
- -trimpath
|
||||||
ldflags:
|
ldflags:
|
||||||
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}}
|
- -X github.com/cosmos/cosmos-sdk/version.Name=sonr
|
||||||
|
- -X github.com/cosmos/cosmos-sdk/version.AppName=sonrd
|
||||||
|
- -X github.com/cosmos/cosmos-sdk/version.Version={{.Version}}
|
||||||
|
- -X github.com/cosmos/cosmos-sdk/version.Commit={{.Commit}}
|
||||||
|
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger"
|
||||||
|
tags:
|
||||||
|
- netgo
|
||||||
|
- ledger
|
||||||
|
|
||||||
|
- id: hway
|
||||||
|
main: ./cmd/hway
|
||||||
|
binary: hway
|
||||||
|
builder: go
|
||||||
|
gobinary: go
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
- darwin
|
||||||
|
goarch:
|
||||||
|
- amd64
|
||||||
|
- arm64
|
||||||
|
mod_timestamp: "{{ .CommitTimestamp }}"
|
||||||
|
flags:
|
||||||
|
- -mod=readonly
|
||||||
|
- -trimpath
|
||||||
|
goamd64:
|
||||||
|
- v1
|
||||||
|
tags:
|
||||||
|
- netgo
|
||||||
|
ldflags:
|
||||||
|
- -X main.version={{.Version}}
|
||||||
|
- -X main.commit={{.Commit}}
|
||||||
|
- -X main.date={{.Date}}
|
||||||
archives:
|
archives:
|
||||||
- id: sonr
|
- id: sonr
|
||||||
builds: [sonr]
|
builds: [sonr]
|
||||||
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
|
name_template: >-
|
||||||
|
sonr_{{ .Version }}_
|
||||||
|
{{- title .Os }}_{{- if eq .Arch "amd64" }}x86_64
|
||||||
|
{{- else if eq .Arch "386" }}i386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
format: tar.gz
|
format: tar.gz
|
||||||
files:
|
files:
|
||||||
- src: README*
|
- src: README*
|
||||||
- src: CHANGELOG*
|
wrap_in_directory: true
|
||||||
|
|
||||||
|
- id: hway
|
||||||
|
builds: [hway]
|
||||||
|
name_template: >-
|
||||||
|
hway_{{ .Version }}_
|
||||||
|
{{- title .Os }}_{{- if eq .Arch "amd64" }}x86_64
|
||||||
|
{{- else if eq .Arch "386" }}i386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
format: tar.gz
|
||||||
|
files:
|
||||||
|
- src: README*
|
||||||
|
wrap_in_directory: true
|
||||||
|
|
||||||
|
nfpms:
|
||||||
|
- id: hway
|
||||||
|
package_name: hway
|
||||||
|
file_name_template: "{{ .ConventionalFileName }}"
|
||||||
|
builds: [hway]
|
||||||
|
vendor: Sonr
|
||||||
|
homepage: "https://onsonr.dev"
|
||||||
|
maintainer: "Sonr <support@onsonr.dev>"
|
||||||
|
description: "Sonr Highway is a decentralized, permissionless, and censorship-resistant identity network proxy."
|
||||||
|
license: "Apache 2.0"
|
||||||
|
formats:
|
||||||
|
- rpm
|
||||||
|
- deb
|
||||||
|
- apk
|
||||||
|
dependencies:
|
||||||
|
- ipfs
|
||||||
|
contents:
|
||||||
|
- src: README*
|
||||||
|
dst: /usr/share/doc/hway
|
||||||
|
bindir: /usr/bin
|
||||||
|
section: net
|
||||||
|
priority: optional
|
||||||
|
# Add these lines to match build config
|
||||||
|
|
||||||
|
- id: sonr
|
||||||
|
package_name: sonrd
|
||||||
|
file_name_template: "{{ .ConventionalFileName }}"
|
||||||
|
builds: [sonr]
|
||||||
|
vendor: Sonr
|
||||||
|
homepage: "https://onsonr.dev"
|
||||||
|
maintainer: "Sonr <support@onsonr.dev>"
|
||||||
|
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||||
|
license: "Apache 2.0"
|
||||||
|
formats:
|
||||||
|
- rpm
|
||||||
|
- deb
|
||||||
|
- apk
|
||||||
|
dependencies:
|
||||||
|
- ipfs
|
||||||
|
contents:
|
||||||
|
- src: README*
|
||||||
|
dst: /usr/share/doc/sonrd
|
||||||
|
bindir: /usr/bin
|
||||||
|
section: net
|
||||||
|
priority: optional
|
||||||
|
# Add these lines to match build config
|
||||||
|
|
||||||
|
brews:
|
||||||
|
- name: hway
|
||||||
|
ids: [hway]
|
||||||
|
commit_author:
|
||||||
|
name: goreleaserbot
|
||||||
|
email: bot@goreleaser.com
|
||||||
|
directory: Formula
|
||||||
|
caveats: "Run a local hway node and access it with the hway proxy"
|
||||||
|
homepage: "https://onsonr.dev"
|
||||||
|
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||||
|
dependencies:
|
||||||
|
- name: ipfs
|
||||||
|
repository:
|
||||||
|
owner: onsonr
|
||||||
|
name: homebrew-tap
|
||||||
|
branch: master
|
||||||
|
token: "{{ .Env.GITHUB_PERSONAL_AUTH_TOKEN }}"
|
||||||
|
|
||||||
|
- name: sonr
|
||||||
|
ids: [sonr]
|
||||||
|
commit_author:
|
||||||
|
name: goreleaserbot
|
||||||
|
email: bot@goreleaser.com
|
||||||
|
directory: Formula
|
||||||
|
caveats: "Run a local sonr node and access it with the hway proxy"
|
||||||
|
homepage: "https://onsonr.dev"
|
||||||
|
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
||||||
|
dependencies:
|
||||||
|
- name: ipfs
|
||||||
|
repository:
|
||||||
|
owner: onsonr
|
||||||
|
name: homebrew-tap
|
||||||
|
branch: master
|
||||||
|
token: "{{ .Env.GITHUB_PERSONAL_AUTH_TOKEN }}"
|
||||||
|
|
||||||
release:
|
release:
|
||||||
github:
|
github:
|
||||||
@@ -32,27 +169,7 @@ release:
|
|||||||
replace_existing_draft: true
|
replace_existing_draft: true
|
||||||
replace_existing_artifacts: true
|
replace_existing_artifacts: true
|
||||||
extra_files:
|
extra_files:
|
||||||
- glob: ./CHANGELOG*
|
|
||||||
- glob: ./README*
|
- glob: ./README*
|
||||||
- glob: ./LICENSE*
|
|
||||||
|
|
||||||
brews:
|
|
||||||
- name: sonr
|
|
||||||
ids: [sonr]
|
|
||||||
commit_author:
|
|
||||||
name: goreleaserbot
|
|
||||||
email: bot@goreleaser.com
|
|
||||||
directory: Formula
|
|
||||||
caveats: "Run a local sonr node and access it with the hway proxy"
|
|
||||||
homepage: "https://sonr.io/"
|
|
||||||
description: "Sonr is a decentralized, permissionless, and censorship-resistant identity network."
|
|
||||||
dependencies:
|
|
||||||
- name: ipfs
|
|
||||||
repository:
|
|
||||||
owner: onsonr
|
|
||||||
name: homebrew-tap
|
|
||||||
branch: master
|
|
||||||
token: "{{ .Env.GITHUB_PERSONAL_AUTH_TOKEN }}"
|
|
||||||
|
|
||||||
announce:
|
announce:
|
||||||
telegram:
|
telegram:
|
||||||
|
|||||||
@@ -8,9 +8,14 @@ SDK_PACK := $(shell go list -m github.com/cosmos/cosmos-sdk | sed 's/ /\@/g')
|
|||||||
BINDIR ?= $(GOPATH)/bin
|
BINDIR ?= $(GOPATH)/bin
|
||||||
SIMAPP = ./app
|
SIMAPP = ./app
|
||||||
|
|
||||||
|
PC_PORT_NUM=42069
|
||||||
|
PC_LOG_FILE=./sonr.log
|
||||||
|
PC_SOCKET_PATH=/tmp/sonr-net.sock
|
||||||
|
|
||||||
# for dockerized protobuf tools
|
# for dockerized protobuf tools
|
||||||
DOCKER := $(shell which docker)
|
DOCKER := $(shell which docker)
|
||||||
HTTPS_GIT := github.com/onsonr/sonr.git
|
HTTPS_GIT := github.com/onsonr/sonr.git
|
||||||
|
PROCESS_COMPOSE := $(shell which process-compose)
|
||||||
|
|
||||||
export GO111MODULE = on
|
export GO111MODULE = on
|
||||||
|
|
||||||
@@ -94,7 +99,6 @@ endif
|
|||||||
|
|
||||||
install: go.sum
|
install: go.sum
|
||||||
go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd
|
go install -mod=readonly $(BUILD_FLAGS) ./cmd/sonrd
|
||||||
go install -mod=readonly $(BUILD_FLAGS) ./cmd/hway
|
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
### Tools & dependencies
|
### Tools & dependencies
|
||||||
@@ -113,12 +117,20 @@ draw-deps:
|
|||||||
@goviz -i ./cmd/sonrd -d 2 | dot -Tpng -o dependency-graph.png
|
@goviz -i ./cmd/sonrd -d 2 | dot -Tpng -o dependency-graph.png
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf pkg/nebula/node_modules
|
rm -rf .aider*
|
||||||
|
rm -rf static
|
||||||
|
rm -rf .out
|
||||||
|
rm -rf hway.db
|
||||||
rm -rf snapcraft-local.yaml build/
|
rm -rf snapcraft-local.yaml build/
|
||||||
|
rm -rf build
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -rf vendor/
|
rm -rf vendor/
|
||||||
|
|
||||||
|
init-env:
|
||||||
|
@echo "Installing process-compose"
|
||||||
|
sh scripts/init_env.sh
|
||||||
|
|
||||||
########################################
|
########################################
|
||||||
### Testing
|
### Testing
|
||||||
|
|
||||||
@@ -172,7 +184,6 @@ format: format-tools
|
|||||||
|
|
||||||
mod-tidy:
|
mod-tidy:
|
||||||
go mod tidy
|
go mod tidy
|
||||||
cd interchaintest && go mod tidy
|
|
||||||
|
|
||||||
.PHONY: format-tools lint format mod-tidy
|
.PHONY: format-tools lint format mod-tidy
|
||||||
|
|
||||||
@@ -263,6 +274,9 @@ ictest-tokenfactory:
|
|||||||
### testnet ###
|
### testnet ###
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
setup-ipfs:
|
||||||
|
./scripts/ipfs_config.sh
|
||||||
|
|
||||||
setup-testnet: mod-tidy is-localic-installed install local-image set-testnet-configs setup-testnet-keys
|
setup-testnet: mod-tidy is-localic-installed install local-image set-testnet-configs setup-testnet-keys
|
||||||
|
|
||||||
# Run this before testnet keys are added
|
# Run this before testnet keys are added
|
||||||
@@ -289,31 +303,71 @@ sh-testnet: mod-tidy
|
|||||||
|
|
||||||
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet
|
.PHONY: setup-testnet set-testnet-configs testnet testnet-basic sh-testnet
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
### generation ###
|
||||||
|
###############################################################################
|
||||||
|
.PHONY: gen-pkl gen-templ gen-sqlc
|
||||||
|
|
||||||
|
gen-pkl: init-env
|
||||||
|
pkl-gen-go pkl/sonr.orm/UCAN.pkl
|
||||||
|
pkl-gen-go pkl/sonr.orm/Models.pkl
|
||||||
|
pkl-gen-go pkl/sonr.net/Hway.pkl
|
||||||
|
pkl-gen-go pkl/sonr.net/Motr.pkl
|
||||||
|
|
||||||
|
gen-sqlc: init-env
|
||||||
|
@cd internal/database && sqlc generate
|
||||||
|
|
||||||
|
gen-templ: init-env
|
||||||
|
@templ generate
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
### custom generation ###
|
### custom builds ###
|
||||||
|
###############################################################################
|
||||||
|
.PHONY: build-motr build-hway logs-hway logs-sonr
|
||||||
|
|
||||||
|
build-motr:
|
||||||
|
GOOS=js GOARCH=wasm go build -o static/wasm/app.wasm ./cmd/motr/main.go
|
||||||
|
|
||||||
|
build-hway: gen-templ
|
||||||
|
go build -o build/hway ./cmd/hway
|
||||||
|
|
||||||
|
logs-hway: init-env
|
||||||
|
bin/process-compose process logs hway --port $(PC_PORT_NUM) --follow
|
||||||
|
|
||||||
|
logs-sonr: init-env
|
||||||
|
bin/process-compose process logs sonr --port $(PC_PORT_NUM) --follow
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
### Network Start/Stop ###
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
.PHONY: templ-gen pkl-gen
|
.PHONY: deploy start start-tui start-uds stop stop-uds restart status
|
||||||
|
|
||||||
assets-gen:
|
start: build-hway init-env
|
||||||
@echo "(assets) Generating gateway cloudflare workers assets"
|
bin/process-compose up --port $(PC_PORT_NUM) --log-file $(PC_LOG_FILE) -f deploy/process-compose.yaml
|
||||||
go run github.com/syumai/workers/cmd/workers-assets-gen -mode=go -o ./cmd/hway/build
|
|
||||||
|
|
||||||
templ-gen:
|
start-uds: build-hway init-env
|
||||||
@echo "(templ) Generating templ files"
|
bin/process-compose up --use-uds --unix-socket $(PC_SOCKET_PATH) --log-file $(PC_LOG_FILE) --detached -f deploy/process-compose.yaml
|
||||||
templ generate
|
|
||||||
|
|
||||||
pkl-gen:
|
stop: init-env
|
||||||
@echo "(pkl) Building PKL"
|
bin/process-compose down --port $(PC_PORT_NUM)
|
||||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/DWN.pkl
|
|
||||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/ORM.pkl
|
|
||||||
go run github.com/apple/pkl-go/cmd/pkl-gen-go ./pkl/Txns.pkl
|
|
||||||
|
|
||||||
|
stop-uds: init-env
|
||||||
|
bin/process-compose down --use-uds --unix-socket $(PC_SOCKET_PATH)
|
||||||
|
|
||||||
|
status: init-env
|
||||||
|
bin/process-compose project state --port $(PC_PORT_NUM)
|
||||||
|
|
||||||
|
status-uds: init-env
|
||||||
|
bin/process-compose project state --use-uds --unix-socket $(PC_SOCKET_PATH)
|
||||||
###############################################################################
|
###############################################################################
|
||||||
### help ###
|
### help ###
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
cd ./proto && bunx buf dep update && bunx buf build && bunx buf push
|
||||||
|
sh ./.github/scripts/upload_cdn.sh
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo "Usage: make <target>"
|
@echo "Usage: make <target>"
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# `sonr` - Sonr Chain
|
# `sonr` - Sonr Chain
|
||||||
|
|
||||||
<center>
|
|
||||||
|
|
||||||
[](https://pkg.go.dev/github.com/onsonr/sonr)
|
[](https://pkg.go.dev/github.com/onsonr/sonr)
|
||||||

|

|
||||||

|

|
||||||
@@ -9,17 +7,23 @@
|
|||||||
[](https://goreportcard.com/report/github.com/onsonr/sonr)
|
[](https://goreportcard.com/report/github.com/onsonr/sonr)
|
||||||
[](https://sonarcloud.io/summary/new_code?id=sonr-io_sonr)
|
[](https://sonarcloud.io/summary/new_code?id=sonr-io_sonr)
|
||||||
|
|
||||||
</center>
|
> Sonr is a combination of decentralized primitives. Fundamentally, it is a peer-to-peer identity and asset management system that leverages DID documents, Webauthn, and IPFS—providing users with a secure, portable decentralized identity.
|
||||||
|
|
||||||
## Overview
|
# Documentation
|
||||||
|
|
||||||
Sonr is a combination of decentralized primitives. Fundamentally, it is a peer-to-peer identity and asset management system that leverages DID documents, Webauthn, and IPFS—providing users with a secure, portable decentralized identity.
|
1. [Quick Start](https://github.com/onsonr/sonr/wiki/1-%E2%80%90-Quick-Start)
|
||||||
|
2. [Chain Modules](https://github.com/onsonr/sonr/wiki/2-%E2%80%90-Chain-Modules)
|
||||||
|
3. [System Architecture](https://github.com/onsonr/sonr/wiki/3-%E2%80%90-System-Architecture)
|
||||||
|
4. [Token Economy](https://github.com/onsonr/sonr/wiki/4-%E2%80%90-Token-Economy)
|
||||||
|
5. [Service Mangement](https://github.com/onsonr/sonr/wiki/5-%E2%80%90-Service-Management)
|
||||||
|
6. [Design System](https://github.com/onsonr/sonr/wiki/6-%E2%80%90-Design-System)
|
||||||
|
7. [Self Custody](https://github.com/onsonr/sonr/wiki/7-%E2%80%90-Self-Custody)
|
||||||
|
|
||||||
## Stats
|
# Stats
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Acknowledgements
|
# Acknowledgements
|
||||||
|
|
||||||
Sonr would not have been possible without the direct and indirect support of the following individuals:
|
Sonr would not have been possible without the direct and indirect support of the following individuals:
|
||||||
|
|
||||||
@@ -28,9 +32,7 @@ Sonr would not have been possible without the direct and indirect support of the
|
|||||||
- **Steve Jobs**: For User first UX.
|
- **Steve Jobs**: For User first UX.
|
||||||
- **Tim Berners-Lee**: For the Internet.
|
- **Tim Berners-Lee**: For the Internet.
|
||||||
|
|
||||||
<br />
|
# Community & Support
|
||||||
|
|
||||||
## Community & Support
|
|
||||||
|
|
||||||
- [Forum](https://github.com/onsonr/sonr/discussions)
|
- [Forum](https://github.com/onsonr/sonr/discussions)
|
||||||
- [Issues](https://github.com/onsonr/sonr/issues)
|
- [Issues](https://github.com/onsonr/sonr/issues)
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
version: "3"
|
|
||||||
|
|
||||||
vars:
|
|
||||||
ROOT_DIR:
|
|
||||||
sh: pwd
|
|
||||||
|
|
||||||
tasks:
|
|
||||||
hway:build:
|
|
||||||
dir: cmd/hway
|
|
||||||
env:
|
|
||||||
GOOS: js
|
|
||||||
GOARCH: wasm
|
|
||||||
cmds:
|
|
||||||
- go build -o build/app.wasm main.go
|
|
||||||
|
|
||||||
hway:dev:
|
|
||||||
dir: cmd/hway
|
|
||||||
cmds:
|
|
||||||
- task: nebula:build
|
|
||||||
- bunx wrangler dev
|
|
||||||
|
|
||||||
hway:deploy:
|
|
||||||
dir: cmd/hway
|
|
||||||
cmds:
|
|
||||||
- bunx wrangler deploy
|
|
||||||
|
|
||||||
motr:build:
|
|
||||||
dir: internal/dwn
|
|
||||||
env:
|
|
||||||
GOOS: js
|
|
||||||
GOARCH: wasm
|
|
||||||
cmds:
|
|
||||||
- go build -o app.wasm wasm/main.go
|
|
||||||
|
|
||||||
nebula:build:
|
|
||||||
dir: pkg/nebula
|
|
||||||
cmds:
|
|
||||||
- bun install
|
|
||||||
- bun run deps.mjs
|
|
||||||
- bunx tailwindcss -i ./global/styles/globals.css -o ./assets/css/styles.css
|
|
||||||
- templ generate
|
|
||||||
@@ -104,9 +104,9 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.did.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: did.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.did.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message did.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,9 +120,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.did.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: did.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.did.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message did.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +136,9 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro
|
|||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.did.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: did.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.did.module.v1.Module does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message did.module.v1.Module does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +156,9 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.did.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: did.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.did.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message did.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.did.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: did.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.did.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message did.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +189,9 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.did.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: did.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.did.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message did.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor
|
|||||||
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in onsonr.sonr.did.module.v1.Module", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in did.module.v1.Module", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -414,29 +414,24 @@ var File_did_module_v1_module_proto protoreflect.FileDescriptor
|
|||||||
|
|
||||||
var file_did_module_v1_module_proto_rawDesc = []byte{
|
var file_did_module_v1_module_proto_rawDesc = []byte{
|
||||||
0x0a, 0x1a, 0x64, 0x69, 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f,
|
0x0a, 0x1a, 0x64, 0x69, 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f,
|
||||||
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x19, 0x6f, 0x6e,
|
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x64, 0x69,
|
||||||
0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x64, 0x69, 0x64, 0x2e, 0x6d, 0x6f,
|
0x64, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73,
|
||||||
0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f,
|
0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||||
0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64,
|
0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x28, 0x0a,
|
||||||
0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2e, 0x0a, 0x06, 0x4d, 0x6f, 0x64,
|
0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x1e, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x18, 0x0a,
|
||||||
0x75, 0x6c, 0x65, 0x3a, 0x24, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x1e, 0x0a, 0x1c, 0x67, 0x69, 0x74,
|
0x16, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f,
|
||||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73,
|
0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x42, 0xa9, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e,
|
||||||
0x6f, 0x6e, 0x72, 0x2f, 0x78, 0x2f, 0x64, 0x69, 0x64, 0x42, 0xe8, 0x01, 0x0a, 0x1d, 0x63, 0x6f,
|
0x64, 0x69, 0x64, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d,
|
||||||
0x6d, 0x2e, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x64, 0x69,
|
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69,
|
||||||
0x64, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64,
|
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f,
|
||||||
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69, 0x74, 0x68,
|
0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x69, 0x64, 0x2f, 0x6d, 0x6f, 0x64,
|
||||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f,
|
0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2,
|
||||||
0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x69, 0x64, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
|
0x02, 0x03, 0x44, 0x4d, 0x58, 0xaa, 0x02, 0x0d, 0x44, 0x69, 0x64, 0x2e, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x04,
|
0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x44, 0x69, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x4f, 0x53, 0x44, 0x4d, 0xaa, 0x02, 0x19, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x53, 0x6f,
|
0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x19, 0x44, 0x69, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x6e, 0x72, 0x2e, 0x44, 0x69, 0x64, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31,
|
0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
||||||
0xca, 0x02, 0x19, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x44,
|
0x61, 0xea, 0x02, 0x0f, 0x44, 0x69, 0x64, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a,
|
||||||
0x69, 0x64, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x25, 0x4f,
|
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x44, 0x69, 0x64, 0x5c, 0x4d,
|
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
|
||||||
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1d, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x53,
|
|
||||||
0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x44, 0x69, 0x64, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
|
|
||||||
0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -453,7 +448,7 @@ func file_did_module_v1_module_proto_rawDescGZIP() []byte {
|
|||||||
|
|
||||||
var file_did_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_did_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_did_module_v1_module_proto_goTypes = []interface{}{
|
var file_did_module_v1_module_proto_goTypes = []interface{}{
|
||||||
(*Module)(nil), // 0: onsonr.sonr.did.module.v1.Module
|
(*Module)(nil), // 0: did.module.v1.Module
|
||||||
}
|
}
|
||||||
var file_did_module_v1_module_proto_depIdxs = []int32{
|
var file_did_module_v1_module_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
|
|||||||
+1196
-4090
File diff suppressed because it is too large
Load Diff
+39
-1263
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,6 @@ const _ = grpc.SupportPackageIsVersion9
|
|||||||
const (
|
const (
|
||||||
Query_Params_FullMethodName = "/did.v1.Query/Params"
|
Query_Params_FullMethodName = "/did.v1.Query/Params"
|
||||||
Query_Resolve_FullMethodName = "/did.v1.Query/Resolve"
|
Query_Resolve_FullMethodName = "/did.v1.Query/Resolve"
|
||||||
Query_Sign_FullMethodName = "/did.v1.Query/Sign"
|
|
||||||
Query_Verify_FullMethodName = "/did.v1.Query/Verify"
|
Query_Verify_FullMethodName = "/did.v1.Query/Verify"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -35,8 +34,6 @@ type QueryClient interface {
|
|||||||
Params(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
Params(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
||||||
// Resolve queries the DID document by its id.
|
// Resolve queries the DID document by its id.
|
||||||
Resolve(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResolveResponse, error)
|
Resolve(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResolveResponse, error)
|
||||||
// Sign signs a message with the DID document
|
|
||||||
Sign(ctx context.Context, in *QuerySignRequest, opts ...grpc.CallOption) (*QuerySignResponse, error)
|
|
||||||
// Verify verifies a message with the DID document
|
// Verify verifies a message with the DID document
|
||||||
Verify(ctx context.Context, in *QueryVerifyRequest, opts ...grpc.CallOption) (*QueryVerifyResponse, error)
|
Verify(ctx context.Context, in *QueryVerifyRequest, opts ...grpc.CallOption) (*QueryVerifyResponse, error)
|
||||||
}
|
}
|
||||||
@@ -69,16 +66,6 @@ func (c *queryClient) Resolve(ctx context.Context, in *QueryRequest, opts ...grp
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *queryClient) Sign(ctx context.Context, in *QuerySignRequest, opts ...grpc.CallOption) (*QuerySignResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(QuerySignResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Query_Sign_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *queryClient) Verify(ctx context.Context, in *QueryVerifyRequest, opts ...grpc.CallOption) (*QueryVerifyResponse, error) {
|
func (c *queryClient) Verify(ctx context.Context, in *QueryVerifyRequest, opts ...grpc.CallOption) (*QueryVerifyResponse, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(QueryVerifyResponse)
|
out := new(QueryVerifyResponse)
|
||||||
@@ -99,8 +86,6 @@ type QueryServer interface {
|
|||||||
Params(context.Context, *QueryRequest) (*QueryParamsResponse, error)
|
Params(context.Context, *QueryRequest) (*QueryParamsResponse, error)
|
||||||
// Resolve queries the DID document by its id.
|
// Resolve queries the DID document by its id.
|
||||||
Resolve(context.Context, *QueryRequest) (*QueryResolveResponse, error)
|
Resolve(context.Context, *QueryRequest) (*QueryResolveResponse, error)
|
||||||
// Sign signs a message with the DID document
|
|
||||||
Sign(context.Context, *QuerySignRequest) (*QuerySignResponse, error)
|
|
||||||
// Verify verifies a message with the DID document
|
// Verify verifies a message with the DID document
|
||||||
Verify(context.Context, *QueryVerifyRequest) (*QueryVerifyResponse, error)
|
Verify(context.Context, *QueryVerifyRequest) (*QueryVerifyResponse, error)
|
||||||
mustEmbedUnimplementedQueryServer()
|
mustEmbedUnimplementedQueryServer()
|
||||||
@@ -119,9 +104,6 @@ func (UnimplementedQueryServer) Params(context.Context, *QueryRequest) (*QueryPa
|
|||||||
func (UnimplementedQueryServer) Resolve(context.Context, *QueryRequest) (*QueryResolveResponse, error) {
|
func (UnimplementedQueryServer) Resolve(context.Context, *QueryRequest) (*QueryResolveResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Resolve not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Resolve not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedQueryServer) Sign(context.Context, *QuerySignRequest) (*QuerySignResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Sign not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedQueryServer) Verify(context.Context, *QueryVerifyRequest) (*QueryVerifyResponse, error) {
|
func (UnimplementedQueryServer) Verify(context.Context, *QueryVerifyRequest) (*QueryVerifyResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Verify not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Verify not implemented")
|
||||||
}
|
}
|
||||||
@@ -182,24 +164,6 @@ func _Query_Resolve_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _Query_Sign_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(QuerySignRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(QueryServer).Sign(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Query_Sign_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(QueryServer).Sign(ctx, req.(*QuerySignRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Query_Verify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Query_Verify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(QueryVerifyRequest)
|
in := new(QueryVerifyRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@@ -233,10 +197,6 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
|||||||
MethodName: "Resolve",
|
MethodName: "Resolve",
|
||||||
Handler: _Query_Resolve_Handler,
|
Handler: _Query_Resolve_Handler,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
MethodName: "Sign",
|
|
||||||
Handler: _Query_Sign_Handler,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
MethodName: "Verify",
|
MethodName: "Verify",
|
||||||
Handler: _Query_Verify_Handler,
|
Handler: _Query_Verify_Handler,
|
||||||
|
|||||||
+170
-339
@@ -9,121 +9,121 @@ import (
|
|||||||
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AssertionTable interface {
|
type AccountTable interface {
|
||||||
Insert(ctx context.Context, assertion *Assertion) error
|
Insert(ctx context.Context, account *Account) error
|
||||||
Update(ctx context.Context, assertion *Assertion) error
|
Update(ctx context.Context, account *Account) error
|
||||||
Save(ctx context.Context, assertion *Assertion) error
|
Save(ctx context.Context, account *Account) error
|
||||||
Delete(ctx context.Context, assertion *Assertion) error
|
Delete(ctx context.Context, account *Account) error
|
||||||
Has(ctx context.Context, did string) (found bool, err error)
|
Has(ctx context.Context, did string) (found bool, err error)
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
Get(ctx context.Context, did string) (*Assertion, error)
|
Get(ctx context.Context, did string) (*Account, error)
|
||||||
HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error)
|
HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error)
|
||||||
// GetByControllerSubject returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// GetByControllerSubject returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
GetByControllerSubject(ctx context.Context, controller string, subject string) (*Assertion, error)
|
GetByControllerSubject(ctx context.Context, controller string, subject string) (*Account, error)
|
||||||
List(ctx context.Context, prefixKey AssertionIndexKey, opts ...ormlist.Option) (AssertionIterator, error)
|
List(ctx context.Context, prefixKey AccountIndexKey, opts ...ormlist.Option) (AccountIterator, error)
|
||||||
ListRange(ctx context.Context, from, to AssertionIndexKey, opts ...ormlist.Option) (AssertionIterator, error)
|
ListRange(ctx context.Context, from, to AccountIndexKey, opts ...ormlist.Option) (AccountIterator, error)
|
||||||
DeleteBy(ctx context.Context, prefixKey AssertionIndexKey) error
|
DeleteBy(ctx context.Context, prefixKey AccountIndexKey) error
|
||||||
DeleteRange(ctx context.Context, from, to AssertionIndexKey) error
|
DeleteRange(ctx context.Context, from, to AccountIndexKey) error
|
||||||
|
|
||||||
doNotImplement()
|
doNotImplement()
|
||||||
}
|
}
|
||||||
|
|
||||||
type AssertionIterator struct {
|
type AccountIterator struct {
|
||||||
ormtable.Iterator
|
ormtable.Iterator
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i AssertionIterator) Value() (*Assertion, error) {
|
func (i AccountIterator) Value() (*Account, error) {
|
||||||
var assertion Assertion
|
var account Account
|
||||||
err := i.UnmarshalMessage(&assertion)
|
err := i.UnmarshalMessage(&account)
|
||||||
return &assertion, err
|
return &account, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type AssertionIndexKey interface {
|
type AccountIndexKey interface {
|
||||||
id() uint32
|
id() uint32
|
||||||
values() []interface{}
|
values() []interface{}
|
||||||
assertionIndexKey()
|
accountIndexKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
// primary key starting index..
|
// primary key starting index..
|
||||||
type AssertionPrimaryKey = AssertionDidIndexKey
|
type AccountPrimaryKey = AccountDidIndexKey
|
||||||
|
|
||||||
type AssertionDidIndexKey struct {
|
type AccountDidIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x AssertionDidIndexKey) id() uint32 { return 0 }
|
func (x AccountDidIndexKey) id() uint32 { return 0 }
|
||||||
func (x AssertionDidIndexKey) values() []interface{} { return x.vs }
|
func (x AccountDidIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x AssertionDidIndexKey) assertionIndexKey() {}
|
func (x AccountDidIndexKey) accountIndexKey() {}
|
||||||
|
|
||||||
func (this AssertionDidIndexKey) WithDid(did string) AssertionDidIndexKey {
|
func (this AccountDidIndexKey) WithDid(did string) AccountDidIndexKey {
|
||||||
this.vs = []interface{}{did}
|
this.vs = []interface{}{did}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type AssertionControllerSubjectIndexKey struct {
|
type AccountControllerSubjectIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x AssertionControllerSubjectIndexKey) id() uint32 { return 1 }
|
func (x AccountControllerSubjectIndexKey) id() uint32 { return 1 }
|
||||||
func (x AssertionControllerSubjectIndexKey) values() []interface{} { return x.vs }
|
func (x AccountControllerSubjectIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x AssertionControllerSubjectIndexKey) assertionIndexKey() {}
|
func (x AccountControllerSubjectIndexKey) accountIndexKey() {}
|
||||||
|
|
||||||
func (this AssertionControllerSubjectIndexKey) WithController(controller string) AssertionControllerSubjectIndexKey {
|
func (this AccountControllerSubjectIndexKey) WithController(controller string) AccountControllerSubjectIndexKey {
|
||||||
this.vs = []interface{}{controller}
|
this.vs = []interface{}{controller}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this AssertionControllerSubjectIndexKey) WithControllerSubject(controller string, subject string) AssertionControllerSubjectIndexKey {
|
func (this AccountControllerSubjectIndexKey) WithControllerSubject(controller string, subject string) AccountControllerSubjectIndexKey {
|
||||||
this.vs = []interface{}{controller, subject}
|
this.vs = []interface{}{controller, subject}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type assertionTable struct {
|
type accountTable struct {
|
||||||
table ormtable.Table
|
table ormtable.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) Insert(ctx context.Context, assertion *Assertion) error {
|
func (this accountTable) Insert(ctx context.Context, account *Account) error {
|
||||||
return this.table.Insert(ctx, assertion)
|
return this.table.Insert(ctx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) Update(ctx context.Context, assertion *Assertion) error {
|
func (this accountTable) Update(ctx context.Context, account *Account) error {
|
||||||
return this.table.Update(ctx, assertion)
|
return this.table.Update(ctx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) Save(ctx context.Context, assertion *Assertion) error {
|
func (this accountTable) Save(ctx context.Context, account *Account) error {
|
||||||
return this.table.Save(ctx, assertion)
|
return this.table.Save(ctx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) Delete(ctx context.Context, assertion *Assertion) error {
|
func (this accountTable) Delete(ctx context.Context, account *Account) error {
|
||||||
return this.table.Delete(ctx, assertion)
|
return this.table.Delete(ctx, account)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) Has(ctx context.Context, did string) (found bool, err error) {
|
func (this accountTable) Has(ctx context.Context, did string) (found bool, err error) {
|
||||||
return this.table.PrimaryKey().Has(ctx, did)
|
return this.table.PrimaryKey().Has(ctx, did)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) Get(ctx context.Context, did string) (*Assertion, error) {
|
func (this accountTable) Get(ctx context.Context, did string) (*Account, error) {
|
||||||
var assertion Assertion
|
var account Account
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &assertion, did)
|
found, err := this.table.PrimaryKey().Get(ctx, &account, did)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &assertion, nil
|
return &account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error) {
|
func (this accountTable) HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error) {
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
||||||
controller,
|
controller,
|
||||||
subject,
|
subject,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) GetByControllerSubject(ctx context.Context, controller string, subject string) (*Assertion, error) {
|
func (this accountTable) GetByControllerSubject(ctx context.Context, controller string, subject string) (*Account, error) {
|
||||||
var assertion Assertion
|
var account Account
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &assertion,
|
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &account,
|
||||||
controller,
|
controller,
|
||||||
subject,
|
subject,
|
||||||
)
|
)
|
||||||
@@ -133,363 +133,206 @@ func (this assertionTable) GetByControllerSubject(ctx context.Context, controlle
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &assertion, nil
|
return &account, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) List(ctx context.Context, prefixKey AssertionIndexKey, opts ...ormlist.Option) (AssertionIterator, error) {
|
func (this accountTable) List(ctx context.Context, prefixKey AccountIndexKey, opts ...ormlist.Option) (AccountIterator, error) {
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
||||||
return AssertionIterator{it}, err
|
return AccountIterator{it}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) ListRange(ctx context.Context, from, to AssertionIndexKey, opts ...ormlist.Option) (AssertionIterator, error) {
|
func (this accountTable) ListRange(ctx context.Context, from, to AccountIndexKey, opts ...ormlist.Option) (AccountIterator, error) {
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
||||||
return AssertionIterator{it}, err
|
return AccountIterator{it}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) DeleteBy(ctx context.Context, prefixKey AssertionIndexKey) error {
|
func (this accountTable) DeleteBy(ctx context.Context, prefixKey AccountIndexKey) error {
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) DeleteRange(ctx context.Context, from, to AssertionIndexKey) error {
|
func (this accountTable) DeleteRange(ctx context.Context, from, to AccountIndexKey) error {
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this assertionTable) doNotImplement() {}
|
func (this accountTable) doNotImplement() {}
|
||||||
|
|
||||||
var _ AssertionTable = assertionTable{}
|
var _ AccountTable = accountTable{}
|
||||||
|
|
||||||
func NewAssertionTable(db ormtable.Schema) (AssertionTable, error) {
|
func NewAccountTable(db ormtable.Schema) (AccountTable, error) {
|
||||||
table := db.GetTable(&Assertion{})
|
table := db.GetTable(&Account{})
|
||||||
if table == nil {
|
if table == nil {
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Assertion{}).ProtoReflect().Descriptor().FullName()))
|
return nil, ormerrors.TableNotFound.Wrap(string((&Account{}).ProtoReflect().Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
return assertionTable{table}, nil
|
return accountTable{table}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthenticationTable interface {
|
type PublicKeyTable interface {
|
||||||
Insert(ctx context.Context, authentication *Authentication) error
|
Insert(ctx context.Context, publicKey *PublicKey) error
|
||||||
Update(ctx context.Context, authentication *Authentication) error
|
InsertReturningNumber(ctx context.Context, publicKey *PublicKey) (uint64, error)
|
||||||
Save(ctx context.Context, authentication *Authentication) error
|
|
||||||
Delete(ctx context.Context, authentication *Authentication) error
|
|
||||||
Has(ctx context.Context, did string) (found bool, err error)
|
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
Get(ctx context.Context, did string) (*Authentication, error)
|
|
||||||
HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error)
|
|
||||||
// GetByControllerSubject returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
GetByControllerSubject(ctx context.Context, controller string, subject string) (*Authentication, error)
|
|
||||||
List(ctx context.Context, prefixKey AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error)
|
|
||||||
ListRange(ctx context.Context, from, to AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error)
|
|
||||||
DeleteBy(ctx context.Context, prefixKey AuthenticationIndexKey) error
|
|
||||||
DeleteRange(ctx context.Context, from, to AuthenticationIndexKey) error
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthenticationIterator struct {
|
|
||||||
ormtable.Iterator
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i AuthenticationIterator) Value() (*Authentication, error) {
|
|
||||||
var authentication Authentication
|
|
||||||
err := i.UnmarshalMessage(&authentication)
|
|
||||||
return &authentication, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthenticationIndexKey interface {
|
|
||||||
id() uint32
|
|
||||||
values() []interface{}
|
|
||||||
authenticationIndexKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
// primary key starting index..
|
|
||||||
type AuthenticationPrimaryKey = AuthenticationDidIndexKey
|
|
||||||
|
|
||||||
type AuthenticationDidIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x AuthenticationDidIndexKey) id() uint32 { return 0 }
|
|
||||||
func (x AuthenticationDidIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x AuthenticationDidIndexKey) authenticationIndexKey() {}
|
|
||||||
|
|
||||||
func (this AuthenticationDidIndexKey) WithDid(did string) AuthenticationDidIndexKey {
|
|
||||||
this.vs = []interface{}{did}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type AuthenticationControllerSubjectIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x AuthenticationControllerSubjectIndexKey) id() uint32 { return 1 }
|
|
||||||
func (x AuthenticationControllerSubjectIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x AuthenticationControllerSubjectIndexKey) authenticationIndexKey() {}
|
|
||||||
|
|
||||||
func (this AuthenticationControllerSubjectIndexKey) WithController(controller string) AuthenticationControllerSubjectIndexKey {
|
|
||||||
this.vs = []interface{}{controller}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this AuthenticationControllerSubjectIndexKey) WithControllerSubject(controller string, subject string) AuthenticationControllerSubjectIndexKey {
|
|
||||||
this.vs = []interface{}{controller, subject}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type authenticationTable struct {
|
|
||||||
table ormtable.Table
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) Insert(ctx context.Context, authentication *Authentication) error {
|
|
||||||
return this.table.Insert(ctx, authentication)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) Update(ctx context.Context, authentication *Authentication) error {
|
|
||||||
return this.table.Update(ctx, authentication)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) Save(ctx context.Context, authentication *Authentication) error {
|
|
||||||
return this.table.Save(ctx, authentication)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) Delete(ctx context.Context, authentication *Authentication) error {
|
|
||||||
return this.table.Delete(ctx, authentication)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) Has(ctx context.Context, did string) (found bool, err error) {
|
|
||||||
return this.table.PrimaryKey().Has(ctx, did)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) Get(ctx context.Context, did string) (*Authentication, error) {
|
|
||||||
var authentication Authentication
|
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &authentication, did)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &authentication, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) HasByControllerSubject(ctx context.Context, controller string, subject string) (found bool, err error) {
|
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
|
||||||
controller,
|
|
||||||
subject,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) GetByControllerSubject(ctx context.Context, controller string, subject string) (*Authentication, error) {
|
|
||||||
var authentication Authentication
|
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &authentication,
|
|
||||||
controller,
|
|
||||||
subject,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &authentication, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) List(ctx context.Context, prefixKey AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
|
||||||
return AuthenticationIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) ListRange(ctx context.Context, from, to AuthenticationIndexKey, opts ...ormlist.Option) (AuthenticationIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
|
||||||
return AuthenticationIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) DeleteBy(ctx context.Context, prefixKey AuthenticationIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) DeleteRange(ctx context.Context, from, to AuthenticationIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this authenticationTable) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ AuthenticationTable = authenticationTable{}
|
|
||||||
|
|
||||||
func NewAuthenticationTable(db ormtable.Schema) (AuthenticationTable, error) {
|
|
||||||
table := db.GetTable(&Authentication{})
|
|
||||||
if table == nil {
|
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Authentication{}).ProtoReflect().Descriptor().FullName()))
|
|
||||||
}
|
|
||||||
return authenticationTable{table}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type ControllerTable interface {
|
|
||||||
Insert(ctx context.Context, controller *Controller) error
|
|
||||||
InsertReturningNumber(ctx context.Context, controller *Controller) (uint64, error)
|
|
||||||
LastInsertedSequence(ctx context.Context) (uint64, error)
|
LastInsertedSequence(ctx context.Context) (uint64, error)
|
||||||
Update(ctx context.Context, controller *Controller) error
|
Update(ctx context.Context, publicKey *PublicKey) error
|
||||||
Save(ctx context.Context, controller *Controller) error
|
Save(ctx context.Context, publicKey *PublicKey) error
|
||||||
Delete(ctx context.Context, controller *Controller) error
|
Delete(ctx context.Context, publicKey *PublicKey) error
|
||||||
Has(ctx context.Context, number uint64) (found bool, err error)
|
Has(ctx context.Context, number uint64) (found bool, err error)
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
Get(ctx context.Context, number uint64) (*Controller, error)
|
Get(ctx context.Context, number uint64) (*PublicKey, error)
|
||||||
HasBySonrAddress(ctx context.Context, sonr_address string) (found bool, err error)
|
HasBySonrAddress(ctx context.Context, sonr_address string) (found bool, err error)
|
||||||
// GetBySonrAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// GetBySonrAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
GetBySonrAddress(ctx context.Context, sonr_address string) (*Controller, error)
|
GetBySonrAddress(ctx context.Context, sonr_address string) (*PublicKey, error)
|
||||||
HasByEthAddress(ctx context.Context, eth_address string) (found bool, err error)
|
HasByEthAddress(ctx context.Context, eth_address string) (found bool, err error)
|
||||||
// GetByEthAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// GetByEthAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
GetByEthAddress(ctx context.Context, eth_address string) (*Controller, error)
|
GetByEthAddress(ctx context.Context, eth_address string) (*PublicKey, error)
|
||||||
HasByBtcAddress(ctx context.Context, btc_address string) (found bool, err error)
|
HasByBtcAddress(ctx context.Context, btc_address string) (found bool, err error)
|
||||||
// GetByBtcAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// GetByBtcAddress returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
GetByBtcAddress(ctx context.Context, btc_address string) (*Controller, error)
|
GetByBtcAddress(ctx context.Context, btc_address string) (*PublicKey, error)
|
||||||
HasByDid(ctx context.Context, did string) (found bool, err error)
|
HasByDid(ctx context.Context, did string) (found bool, err error)
|
||||||
// GetByDid returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// GetByDid returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
GetByDid(ctx context.Context, did string) (*Controller, error)
|
GetByDid(ctx context.Context, did string) (*PublicKey, error)
|
||||||
List(ctx context.Context, prefixKey ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error)
|
List(ctx context.Context, prefixKey PublicKeyIndexKey, opts ...ormlist.Option) (PublicKeyIterator, error)
|
||||||
ListRange(ctx context.Context, from, to ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error)
|
ListRange(ctx context.Context, from, to PublicKeyIndexKey, opts ...ormlist.Option) (PublicKeyIterator, error)
|
||||||
DeleteBy(ctx context.Context, prefixKey ControllerIndexKey) error
|
DeleteBy(ctx context.Context, prefixKey PublicKeyIndexKey) error
|
||||||
DeleteRange(ctx context.Context, from, to ControllerIndexKey) error
|
DeleteRange(ctx context.Context, from, to PublicKeyIndexKey) error
|
||||||
|
|
||||||
doNotImplement()
|
doNotImplement()
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControllerIterator struct {
|
type PublicKeyIterator struct {
|
||||||
ormtable.Iterator
|
ormtable.Iterator
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i ControllerIterator) Value() (*Controller, error) {
|
func (i PublicKeyIterator) Value() (*PublicKey, error) {
|
||||||
var controller Controller
|
var publicKey PublicKey
|
||||||
err := i.UnmarshalMessage(&controller)
|
err := i.UnmarshalMessage(&publicKey)
|
||||||
return &controller, err
|
return &publicKey, err
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControllerIndexKey interface {
|
type PublicKeyIndexKey interface {
|
||||||
id() uint32
|
id() uint32
|
||||||
values() []interface{}
|
values() []interface{}
|
||||||
controllerIndexKey()
|
publicKeyIndexKey()
|
||||||
}
|
}
|
||||||
|
|
||||||
// primary key starting index..
|
// primary key starting index..
|
||||||
type ControllerPrimaryKey = ControllerNumberIndexKey
|
type PublicKeyPrimaryKey = PublicKeyNumberIndexKey
|
||||||
|
|
||||||
type ControllerNumberIndexKey struct {
|
type PublicKeyNumberIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x ControllerNumberIndexKey) id() uint32 { return 0 }
|
func (x PublicKeyNumberIndexKey) id() uint32 { return 0 }
|
||||||
func (x ControllerNumberIndexKey) values() []interface{} { return x.vs }
|
func (x PublicKeyNumberIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x ControllerNumberIndexKey) controllerIndexKey() {}
|
func (x PublicKeyNumberIndexKey) publicKeyIndexKey() {}
|
||||||
|
|
||||||
func (this ControllerNumberIndexKey) WithNumber(number uint64) ControllerNumberIndexKey {
|
func (this PublicKeyNumberIndexKey) WithNumber(number uint64) PublicKeyNumberIndexKey {
|
||||||
this.vs = []interface{}{number}
|
this.vs = []interface{}{number}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControllerSonrAddressIndexKey struct {
|
type PublicKeySonrAddressIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x ControllerSonrAddressIndexKey) id() uint32 { return 1 }
|
func (x PublicKeySonrAddressIndexKey) id() uint32 { return 1 }
|
||||||
func (x ControllerSonrAddressIndexKey) values() []interface{} { return x.vs }
|
func (x PublicKeySonrAddressIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x ControllerSonrAddressIndexKey) controllerIndexKey() {}
|
func (x PublicKeySonrAddressIndexKey) publicKeyIndexKey() {}
|
||||||
|
|
||||||
func (this ControllerSonrAddressIndexKey) WithSonrAddress(sonr_address string) ControllerSonrAddressIndexKey {
|
func (this PublicKeySonrAddressIndexKey) WithSonrAddress(sonr_address string) PublicKeySonrAddressIndexKey {
|
||||||
this.vs = []interface{}{sonr_address}
|
this.vs = []interface{}{sonr_address}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControllerEthAddressIndexKey struct {
|
type PublicKeyEthAddressIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x ControllerEthAddressIndexKey) id() uint32 { return 2 }
|
func (x PublicKeyEthAddressIndexKey) id() uint32 { return 2 }
|
||||||
func (x ControllerEthAddressIndexKey) values() []interface{} { return x.vs }
|
func (x PublicKeyEthAddressIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x ControllerEthAddressIndexKey) controllerIndexKey() {}
|
func (x PublicKeyEthAddressIndexKey) publicKeyIndexKey() {}
|
||||||
|
|
||||||
func (this ControllerEthAddressIndexKey) WithEthAddress(eth_address string) ControllerEthAddressIndexKey {
|
func (this PublicKeyEthAddressIndexKey) WithEthAddress(eth_address string) PublicKeyEthAddressIndexKey {
|
||||||
this.vs = []interface{}{eth_address}
|
this.vs = []interface{}{eth_address}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControllerBtcAddressIndexKey struct {
|
type PublicKeyBtcAddressIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x ControllerBtcAddressIndexKey) id() uint32 { return 3 }
|
func (x PublicKeyBtcAddressIndexKey) id() uint32 { return 3 }
|
||||||
func (x ControllerBtcAddressIndexKey) values() []interface{} { return x.vs }
|
func (x PublicKeyBtcAddressIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x ControllerBtcAddressIndexKey) controllerIndexKey() {}
|
func (x PublicKeyBtcAddressIndexKey) publicKeyIndexKey() {}
|
||||||
|
|
||||||
func (this ControllerBtcAddressIndexKey) WithBtcAddress(btc_address string) ControllerBtcAddressIndexKey {
|
func (this PublicKeyBtcAddressIndexKey) WithBtcAddress(btc_address string) PublicKeyBtcAddressIndexKey {
|
||||||
this.vs = []interface{}{btc_address}
|
this.vs = []interface{}{btc_address}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type ControllerDidIndexKey struct {
|
type PublicKeyDidIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x ControllerDidIndexKey) id() uint32 { return 4 }
|
func (x PublicKeyDidIndexKey) id() uint32 { return 4 }
|
||||||
func (x ControllerDidIndexKey) values() []interface{} { return x.vs }
|
func (x PublicKeyDidIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x ControllerDidIndexKey) controllerIndexKey() {}
|
func (x PublicKeyDidIndexKey) publicKeyIndexKey() {}
|
||||||
|
|
||||||
func (this ControllerDidIndexKey) WithDid(did string) ControllerDidIndexKey {
|
func (this PublicKeyDidIndexKey) WithDid(did string) PublicKeyDidIndexKey {
|
||||||
this.vs = []interface{}{did}
|
this.vs = []interface{}{did}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type controllerTable struct {
|
type publicKeyTable struct {
|
||||||
table ormtable.AutoIncrementTable
|
table ormtable.AutoIncrementTable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) Insert(ctx context.Context, controller *Controller) error {
|
func (this publicKeyTable) Insert(ctx context.Context, publicKey *PublicKey) error {
|
||||||
return this.table.Insert(ctx, controller)
|
return this.table.Insert(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) Update(ctx context.Context, controller *Controller) error {
|
func (this publicKeyTable) Update(ctx context.Context, publicKey *PublicKey) error {
|
||||||
return this.table.Update(ctx, controller)
|
return this.table.Update(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) Save(ctx context.Context, controller *Controller) error {
|
func (this publicKeyTable) Save(ctx context.Context, publicKey *PublicKey) error {
|
||||||
return this.table.Save(ctx, controller)
|
return this.table.Save(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) Delete(ctx context.Context, controller *Controller) error {
|
func (this publicKeyTable) Delete(ctx context.Context, publicKey *PublicKey) error {
|
||||||
return this.table.Delete(ctx, controller)
|
return this.table.Delete(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) InsertReturningNumber(ctx context.Context, controller *Controller) (uint64, error) {
|
func (this publicKeyTable) InsertReturningNumber(ctx context.Context, publicKey *PublicKey) (uint64, error) {
|
||||||
return this.table.InsertReturningPKey(ctx, controller)
|
return this.table.InsertReturningPKey(ctx, publicKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
func (this publicKeyTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
||||||
return this.table.LastInsertedSequence(ctx)
|
return this.table.LastInsertedSequence(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) Has(ctx context.Context, number uint64) (found bool, err error) {
|
func (this publicKeyTable) Has(ctx context.Context, number uint64) (found bool, err error) {
|
||||||
return this.table.PrimaryKey().Has(ctx, number)
|
return this.table.PrimaryKey().Has(ctx, number)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) Get(ctx context.Context, number uint64) (*Controller, error) {
|
func (this publicKeyTable) Get(ctx context.Context, number uint64) (*PublicKey, error) {
|
||||||
var controller Controller
|
var publicKey PublicKey
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &controller, number)
|
found, err := this.table.PrimaryKey().Get(ctx, &publicKey, number)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &controller, nil
|
return &publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) HasBySonrAddress(ctx context.Context, sonr_address string) (found bool, err error) {
|
func (this publicKeyTable) HasBySonrAddress(ctx context.Context, sonr_address string) (found bool, err error) {
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
||||||
sonr_address,
|
sonr_address,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) GetBySonrAddress(ctx context.Context, sonr_address string) (*Controller, error) {
|
func (this publicKeyTable) GetBySonrAddress(ctx context.Context, sonr_address string) (*PublicKey, error) {
|
||||||
var controller Controller
|
var publicKey PublicKey
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &controller,
|
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &publicKey,
|
||||||
sonr_address,
|
sonr_address,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -498,18 +341,18 @@ func (this controllerTable) GetBySonrAddress(ctx context.Context, sonr_address s
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &controller, nil
|
return &publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) HasByEthAddress(ctx context.Context, eth_address string) (found bool, err error) {
|
func (this publicKeyTable) HasByEthAddress(ctx context.Context, eth_address string) (found bool, err error) {
|
||||||
return this.table.GetIndexByID(2).(ormtable.UniqueIndex).Has(ctx,
|
return this.table.GetIndexByID(2).(ormtable.UniqueIndex).Has(ctx,
|
||||||
eth_address,
|
eth_address,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) GetByEthAddress(ctx context.Context, eth_address string) (*Controller, error) {
|
func (this publicKeyTable) GetByEthAddress(ctx context.Context, eth_address string) (*PublicKey, error) {
|
||||||
var controller Controller
|
var publicKey PublicKey
|
||||||
found, err := this.table.GetIndexByID(2).(ormtable.UniqueIndex).Get(ctx, &controller,
|
found, err := this.table.GetIndexByID(2).(ormtable.UniqueIndex).Get(ctx, &publicKey,
|
||||||
eth_address,
|
eth_address,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -518,18 +361,18 @@ func (this controllerTable) GetByEthAddress(ctx context.Context, eth_address str
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &controller, nil
|
return &publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) HasByBtcAddress(ctx context.Context, btc_address string) (found bool, err error) {
|
func (this publicKeyTable) HasByBtcAddress(ctx context.Context, btc_address string) (found bool, err error) {
|
||||||
return this.table.GetIndexByID(3).(ormtable.UniqueIndex).Has(ctx,
|
return this.table.GetIndexByID(3).(ormtable.UniqueIndex).Has(ctx,
|
||||||
btc_address,
|
btc_address,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) GetByBtcAddress(ctx context.Context, btc_address string) (*Controller, error) {
|
func (this publicKeyTable) GetByBtcAddress(ctx context.Context, btc_address string) (*PublicKey, error) {
|
||||||
var controller Controller
|
var publicKey PublicKey
|
||||||
found, err := this.table.GetIndexByID(3).(ormtable.UniqueIndex).Get(ctx, &controller,
|
found, err := this.table.GetIndexByID(3).(ormtable.UniqueIndex).Get(ctx, &publicKey,
|
||||||
btc_address,
|
btc_address,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -538,18 +381,18 @@ func (this controllerTable) GetByBtcAddress(ctx context.Context, btc_address str
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &controller, nil
|
return &publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) HasByDid(ctx context.Context, did string) (found bool, err error) {
|
func (this publicKeyTable) HasByDid(ctx context.Context, did string) (found bool, err error) {
|
||||||
return this.table.GetIndexByID(4).(ormtable.UniqueIndex).Has(ctx,
|
return this.table.GetIndexByID(4).(ormtable.UniqueIndex).Has(ctx,
|
||||||
did,
|
did,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) GetByDid(ctx context.Context, did string) (*Controller, error) {
|
func (this publicKeyTable) GetByDid(ctx context.Context, did string) (*PublicKey, error) {
|
||||||
var controller Controller
|
var publicKey PublicKey
|
||||||
found, err := this.table.GetIndexByID(4).(ormtable.UniqueIndex).Get(ctx, &controller,
|
found, err := this.table.GetIndexByID(4).(ormtable.UniqueIndex).Get(ctx, &publicKey,
|
||||||
did,
|
did,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -558,37 +401,37 @@ func (this controllerTable) GetByDid(ctx context.Context, did string) (*Controll
|
|||||||
if !found {
|
if !found {
|
||||||
return nil, ormerrors.NotFound
|
return nil, ormerrors.NotFound
|
||||||
}
|
}
|
||||||
return &controller, nil
|
return &publicKey, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) List(ctx context.Context, prefixKey ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error) {
|
func (this publicKeyTable) List(ctx context.Context, prefixKey PublicKeyIndexKey, opts ...ormlist.Option) (PublicKeyIterator, error) {
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
||||||
return ControllerIterator{it}, err
|
return PublicKeyIterator{it}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) ListRange(ctx context.Context, from, to ControllerIndexKey, opts ...ormlist.Option) (ControllerIterator, error) {
|
func (this publicKeyTable) ListRange(ctx context.Context, from, to PublicKeyIndexKey, opts ...ormlist.Option) (PublicKeyIterator, error) {
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
||||||
return ControllerIterator{it}, err
|
return PublicKeyIterator{it}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) DeleteBy(ctx context.Context, prefixKey ControllerIndexKey) error {
|
func (this publicKeyTable) DeleteBy(ctx context.Context, prefixKey PublicKeyIndexKey) error {
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) DeleteRange(ctx context.Context, from, to ControllerIndexKey) error {
|
func (this publicKeyTable) DeleteRange(ctx context.Context, from, to PublicKeyIndexKey) error {
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this controllerTable) doNotImplement() {}
|
func (this publicKeyTable) doNotImplement() {}
|
||||||
|
|
||||||
var _ ControllerTable = controllerTable{}
|
var _ PublicKeyTable = publicKeyTable{}
|
||||||
|
|
||||||
func NewControllerTable(db ormtable.Schema) (ControllerTable, error) {
|
func NewPublicKeyTable(db ormtable.Schema) (PublicKeyTable, error) {
|
||||||
table := db.GetTable(&Controller{})
|
table := db.GetTable(&PublicKey{})
|
||||||
if table == nil {
|
if table == nil {
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Controller{}).ProtoReflect().Descriptor().FullName()))
|
return nil, ormerrors.TableNotFound.Wrap(string((&PublicKey{}).ProtoReflect().Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
return controllerTable{table.(ormtable.AutoIncrementTable)}, nil
|
return publicKeyTable{table.(ormtable.AutoIncrementTable)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerificationTable interface {
|
type VerificationTable interface {
|
||||||
@@ -849,31 +692,25 @@ func NewVerificationTable(db ormtable.Schema) (VerificationTable, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type StateStore interface {
|
type StateStore interface {
|
||||||
AssertionTable() AssertionTable
|
AccountTable() AccountTable
|
||||||
AuthenticationTable() AuthenticationTable
|
PublicKeyTable() PublicKeyTable
|
||||||
ControllerTable() ControllerTable
|
|
||||||
VerificationTable() VerificationTable
|
VerificationTable() VerificationTable
|
||||||
|
|
||||||
doNotImplement()
|
doNotImplement()
|
||||||
}
|
}
|
||||||
|
|
||||||
type stateStore struct {
|
type stateStore struct {
|
||||||
assertion AssertionTable
|
account AccountTable
|
||||||
authentication AuthenticationTable
|
publicKey PublicKeyTable
|
||||||
controller ControllerTable
|
|
||||||
verification VerificationTable
|
verification VerificationTable
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x stateStore) AssertionTable() AssertionTable {
|
func (x stateStore) AccountTable() AccountTable {
|
||||||
return x.assertion
|
return x.account
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x stateStore) AuthenticationTable() AuthenticationTable {
|
func (x stateStore) PublicKeyTable() PublicKeyTable {
|
||||||
return x.authentication
|
return x.publicKey
|
||||||
}
|
|
||||||
|
|
||||||
func (x stateStore) ControllerTable() ControllerTable {
|
|
||||||
return x.controller
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x stateStore) VerificationTable() VerificationTable {
|
func (x stateStore) VerificationTable() VerificationTable {
|
||||||
@@ -885,17 +722,12 @@ func (stateStore) doNotImplement() {}
|
|||||||
var _ StateStore = stateStore{}
|
var _ StateStore = stateStore{}
|
||||||
|
|
||||||
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
||||||
assertionTable, err := NewAssertionTable(db)
|
accountTable, err := NewAccountTable(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
authenticationTable, err := NewAuthenticationTable(db)
|
publicKeyTable, err := NewPublicKeyTable(db)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
controllerTable, err := NewControllerTable(db)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -906,9 +738,8 @@ func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return stateStore{
|
return stateStore{
|
||||||
assertionTable,
|
accountTable,
|
||||||
authenticationTable,
|
publicKeyTable,
|
||||||
controllerTable,
|
|
||||||
verificationTable,
|
verificationTable,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+510
-1736
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_vault_module_v1_module_proto_init()
|
file_dwn_module_v1_module_proto_init()
|
||||||
md_Module = File_vault_module_v1_module_proto.Messages().ByName("Module")
|
md_Module = File_dwn_module_v1_module_proto.Messages().ByName("Module")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
||||||
@@ -31,7 +31,7 @@ func (x *Module) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *Module) slowProtoReflect() protoreflect.Message {
|
func (x *Module) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_vault_module_v1_module_proto_msgTypes[0]
|
mi := &file_dwn_module_v1_module_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -104,9 +104,9 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.vault.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.vault.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message dwn.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,9 +120,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.vault.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.vault.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message dwn.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +136,9 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro
|
|||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.vault.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.vault.module.v1.Module does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message dwn.module.v1.Module does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +156,9 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.vault.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.vault.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message dwn.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.vault.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.vault.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message dwn.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +189,9 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.vault.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: dwn.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.vault.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message dwn.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor
|
|||||||
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in onsonr.sonr.vault.module.v1.Module", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in dwn.module.v1.Module", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,7 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.27.0
|
// protoc-gen-go v1.27.0
|
||||||
// protoc (unknown)
|
// protoc (unknown)
|
||||||
// source: vault/module/v1/module.proto
|
// source: dwn/module/v1/module.proto
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
@@ -393,7 +393,7 @@ type Module struct {
|
|||||||
func (x *Module) Reset() {
|
func (x *Module) Reset() {
|
||||||
*x = Module{}
|
*x = Module{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_vault_module_v1_module_proto_msgTypes[0]
|
mi := &file_dwn_module_v1_module_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -407,56 +407,50 @@ func (*Module) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use Module.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Module.ProtoReflect.Descriptor instead.
|
||||||
func (*Module) Descriptor() ([]byte, []int) {
|
func (*Module) Descriptor() ([]byte, []int) {
|
||||||
return file_vault_module_v1_module_proto_rawDescGZIP(), []int{0}
|
return file_dwn_module_v1_module_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_vault_module_v1_module_proto protoreflect.FileDescriptor
|
var File_dwn_module_v1_module_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_vault_module_v1_module_proto_rawDesc = []byte{
|
var file_dwn_module_v1_module_proto_rawDesc = []byte{
|
||||||
0x0a, 0x1c, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76,
|
0x0a, 0x1a, 0x64, 0x77, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f,
|
||||||
0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x1b,
|
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x64, 0x77,
|
||||||
0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c,
|
0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73,
|
||||||
0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73,
|
|
||||||
0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||||
0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x30, 0x0a,
|
0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x28, 0x0a,
|
||||||
0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x26, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x20, 0x0a,
|
0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x1e, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x18, 0x0a,
|
||||||
0x1e, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f,
|
0x16, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f,
|
||||||
0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x78, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x42,
|
0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x42, 0xa9, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e,
|
||||||
0xf4, 0x01, 0x0a, 0x1f, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73,
|
0x64, 0x77, 0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d,
|
||||||
0x6f, 0x6e, 0x72, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
|
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69,
|
||||||
0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f,
|
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f,
|
||||||
0x50, 0x01, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f,
|
0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x64, 0x77, 0x6e, 0x2f, 0x6d, 0x6f, 0x64,
|
||||||
0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76,
|
0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2,
|
||||||
0x61, 0x75, 0x6c, 0x74, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d,
|
0x02, 0x03, 0x44, 0x4d, 0x58, 0xaa, 0x02, 0x0d, 0x44, 0x77, 0x6e, 0x2e, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x04, 0x4f, 0x53, 0x56, 0x4d, 0xaa, 0x02,
|
0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x44, 0x77, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x1b, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x53, 0x6f, 0x6e, 0x72, 0x2e, 0x56, 0x61, 0x75,
|
0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x19, 0x44, 0x77, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x6c, 0x74, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x1b, 0x4f,
|
0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
||||||
0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x56, 0x61, 0x75, 0x6c, 0x74,
|
0x61, 0xea, 0x02, 0x0f, 0x44, 0x77, 0x6e, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a,
|
||||||
0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x27, 0x4f, 0x6e, 0x73,
|
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x5c, 0x4d,
|
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
|
||||||
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x1f, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x53,
|
|
||||||
0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75,
|
|
||||||
0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_vault_module_v1_module_proto_rawDescOnce sync.Once
|
file_dwn_module_v1_module_proto_rawDescOnce sync.Once
|
||||||
file_vault_module_v1_module_proto_rawDescData = file_vault_module_v1_module_proto_rawDesc
|
file_dwn_module_v1_module_proto_rawDescData = file_dwn_module_v1_module_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_vault_module_v1_module_proto_rawDescGZIP() []byte {
|
func file_dwn_module_v1_module_proto_rawDescGZIP() []byte {
|
||||||
file_vault_module_v1_module_proto_rawDescOnce.Do(func() {
|
file_dwn_module_v1_module_proto_rawDescOnce.Do(func() {
|
||||||
file_vault_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_vault_module_v1_module_proto_rawDescData)
|
file_dwn_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_dwn_module_v1_module_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_vault_module_v1_module_proto_rawDescData
|
return file_dwn_module_v1_module_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_vault_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_dwn_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_vault_module_v1_module_proto_goTypes = []interface{}{
|
var file_dwn_module_v1_module_proto_goTypes = []interface{}{
|
||||||
(*Module)(nil), // 0: onsonr.sonr.vault.module.v1.Module
|
(*Module)(nil), // 0: dwn.module.v1.Module
|
||||||
}
|
}
|
||||||
var file_vault_module_v1_module_proto_depIdxs = []int32{
|
var file_dwn_module_v1_module_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
0, // [0:0] is the sub-list for method input_type
|
0, // [0:0] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
@@ -464,13 +458,13 @@ var file_vault_module_v1_module_proto_depIdxs = []int32{
|
|||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_vault_module_v1_module_proto_init() }
|
func init() { file_dwn_module_v1_module_proto_init() }
|
||||||
func file_vault_module_v1_module_proto_init() {
|
func file_dwn_module_v1_module_proto_init() {
|
||||||
if File_vault_module_v1_module_proto != nil {
|
if File_dwn_module_v1_module_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_vault_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_dwn_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*Module); i {
|
switch v := v.(*Module); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -487,18 +481,18 @@ func file_vault_module_v1_module_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_vault_module_v1_module_proto_rawDesc,
|
RawDescriptor: file_dwn_module_v1_module_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 1,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_vault_module_v1_module_proto_goTypes,
|
GoTypes: file_dwn_module_v1_module_proto_goTypes,
|
||||||
DependencyIndexes: file_vault_module_v1_module_proto_depIdxs,
|
DependencyIndexes: file_dwn_module_v1_module_proto_depIdxs,
|
||||||
MessageInfos: file_vault_module_v1_module_proto_msgTypes,
|
MessageInfos: file_dwn_module_v1_module_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_vault_module_v1_module_proto = out.File
|
File_dwn_module_v1_module_proto = out.File
|
||||||
file_vault_module_v1_module_proto_rawDesc = nil
|
file_dwn_module_v1_module_proto_rawDesc = nil
|
||||||
file_vault_module_v1_module_proto_goTypes = nil
|
file_dwn_module_v1_module_proto_goTypes = nil
|
||||||
file_vault_module_v1_module_proto_depIdxs = nil
|
file_dwn_module_v1_module_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
// - protoc (unknown)
|
// - protoc (unknown)
|
||||||
// source: vault/v1/query.proto
|
// source: dwn/v1/query.proto
|
||||||
|
|
||||||
package vaultv1
|
package dwnv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
@@ -19,10 +19,10 @@ import (
|
|||||||
const _ = grpc.SupportPackageIsVersion9
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Query_Params_FullMethodName = "/vault.v1.Query/Params"
|
Query_Params_FullMethodName = "/dwn.v1.Query/Params"
|
||||||
Query_Schema_FullMethodName = "/vault.v1.Query/Schema"
|
Query_Schema_FullMethodName = "/dwn.v1.Query/Schema"
|
||||||
Query_Allocate_FullMethodName = "/vault.v1.Query/Allocate"
|
Query_Allocate_FullMethodName = "/dwn.v1.Query/Allocate"
|
||||||
Query_Sync_FullMethodName = "/vault.v1.Query/Sync"
|
Query_Sync_FullMethodName = "/dwn.v1.Query/Sync"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryClient is the client API for Query service.
|
// QueryClient is the client API for Query service.
|
||||||
@@ -228,7 +228,7 @@ func _Query_Sync_Handler(srv interface{}, ctx context.Context, dec func(interfac
|
|||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
var Query_ServiceDesc = grpc.ServiceDesc{
|
var Query_ServiceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "vault.v1.Query",
|
ServiceName: "dwn.v1.Query",
|
||||||
HandlerType: (*QueryServer)(nil),
|
HandlerType: (*QueryServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
@@ -249,5 +249,5 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "vault/v1/query.proto",
|
Metadata: "dwn/v1/query.proto",
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,292 @@
|
|||||||
|
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
||||||
|
|
||||||
|
package dwnv1
|
||||||
|
|
||||||
|
import (
|
||||||
|
context "context"
|
||||||
|
ormlist "cosmossdk.io/orm/model/ormlist"
|
||||||
|
ormtable "cosmossdk.io/orm/model/ormtable"
|
||||||
|
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type CredentialTable interface {
|
||||||
|
Insert(ctx context.Context, credential *Credential) error
|
||||||
|
Update(ctx context.Context, credential *Credential) error
|
||||||
|
Save(ctx context.Context, credential *Credential) error
|
||||||
|
Delete(ctx context.Context, credential *Credential) error
|
||||||
|
Has(ctx context.Context, id []byte) (found bool, err error)
|
||||||
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
|
Get(ctx context.Context, id []byte) (*Credential, error)
|
||||||
|
List(ctx context.Context, prefixKey CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error)
|
||||||
|
ListRange(ctx context.Context, from, to CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error)
|
||||||
|
DeleteBy(ctx context.Context, prefixKey CredentialIndexKey) error
|
||||||
|
DeleteRange(ctx context.Context, from, to CredentialIndexKey) error
|
||||||
|
|
||||||
|
doNotImplement()
|
||||||
|
}
|
||||||
|
|
||||||
|
type CredentialIterator struct {
|
||||||
|
ormtable.Iterator
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i CredentialIterator) Value() (*Credential, error) {
|
||||||
|
var credential Credential
|
||||||
|
err := i.UnmarshalMessage(&credential)
|
||||||
|
return &credential, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type CredentialIndexKey interface {
|
||||||
|
id() uint32
|
||||||
|
values() []interface{}
|
||||||
|
credentialIndexKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
// primary key starting index..
|
||||||
|
type CredentialPrimaryKey = CredentialIdIndexKey
|
||||||
|
|
||||||
|
type CredentialIdIndexKey struct {
|
||||||
|
vs []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x CredentialIdIndexKey) id() uint32 { return 0 }
|
||||||
|
func (x CredentialIdIndexKey) values() []interface{} { return x.vs }
|
||||||
|
func (x CredentialIdIndexKey) credentialIndexKey() {}
|
||||||
|
|
||||||
|
func (this CredentialIdIndexKey) WithId(id []byte) CredentialIdIndexKey {
|
||||||
|
this.vs = []interface{}{id}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
type credentialTable struct {
|
||||||
|
table ormtable.Table
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) Insert(ctx context.Context, credential *Credential) error {
|
||||||
|
return this.table.Insert(ctx, credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) Update(ctx context.Context, credential *Credential) error {
|
||||||
|
return this.table.Update(ctx, credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) Save(ctx context.Context, credential *Credential) error {
|
||||||
|
return this.table.Save(ctx, credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) Delete(ctx context.Context, credential *Credential) error {
|
||||||
|
return this.table.Delete(ctx, credential)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) Has(ctx context.Context, id []byte) (found bool, err error) {
|
||||||
|
return this.table.PrimaryKey().Has(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) Get(ctx context.Context, id []byte) (*Credential, error) {
|
||||||
|
var credential Credential
|
||||||
|
found, err := this.table.PrimaryKey().Get(ctx, &credential, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, ormerrors.NotFound
|
||||||
|
}
|
||||||
|
return &credential, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) List(ctx context.Context, prefixKey CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error) {
|
||||||
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
||||||
|
return CredentialIterator{it}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) ListRange(ctx context.Context, from, to CredentialIndexKey, opts ...ormlist.Option) (CredentialIterator, error) {
|
||||||
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
||||||
|
return CredentialIterator{it}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) DeleteBy(ctx context.Context, prefixKey CredentialIndexKey) error {
|
||||||
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) DeleteRange(ctx context.Context, from, to CredentialIndexKey) error {
|
||||||
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this credentialTable) doNotImplement() {}
|
||||||
|
|
||||||
|
var _ CredentialTable = credentialTable{}
|
||||||
|
|
||||||
|
func NewCredentialTable(db ormtable.Schema) (CredentialTable, error) {
|
||||||
|
table := db.GetTable(&Credential{})
|
||||||
|
if table == nil {
|
||||||
|
return nil, ormerrors.TableNotFound.Wrap(string((&Credential{}).ProtoReflect().Descriptor().FullName()))
|
||||||
|
}
|
||||||
|
return credentialTable{table}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfileTable interface {
|
||||||
|
Insert(ctx context.Context, profile *Profile) error
|
||||||
|
Update(ctx context.Context, profile *Profile) error
|
||||||
|
Save(ctx context.Context, profile *Profile) error
|
||||||
|
Delete(ctx context.Context, profile *Profile) error
|
||||||
|
Has(ctx context.Context, account []byte) (found bool, err error)
|
||||||
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
|
Get(ctx context.Context, account []byte) (*Profile, error)
|
||||||
|
List(ctx context.Context, prefixKey ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error)
|
||||||
|
ListRange(ctx context.Context, from, to ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error)
|
||||||
|
DeleteBy(ctx context.Context, prefixKey ProfileIndexKey) error
|
||||||
|
DeleteRange(ctx context.Context, from, to ProfileIndexKey) error
|
||||||
|
|
||||||
|
doNotImplement()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfileIterator struct {
|
||||||
|
ormtable.Iterator
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i ProfileIterator) Value() (*Profile, error) {
|
||||||
|
var profile Profile
|
||||||
|
err := i.UnmarshalMessage(&profile)
|
||||||
|
return &profile, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfileIndexKey interface {
|
||||||
|
id() uint32
|
||||||
|
values() []interface{}
|
||||||
|
profileIndexKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
// primary key starting index..
|
||||||
|
type ProfilePrimaryKey = ProfileAccountIndexKey
|
||||||
|
|
||||||
|
type ProfileAccountIndexKey struct {
|
||||||
|
vs []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x ProfileAccountIndexKey) id() uint32 { return 0 }
|
||||||
|
func (x ProfileAccountIndexKey) values() []interface{} { return x.vs }
|
||||||
|
func (x ProfileAccountIndexKey) profileIndexKey() {}
|
||||||
|
|
||||||
|
func (this ProfileAccountIndexKey) WithAccount(account []byte) ProfileAccountIndexKey {
|
||||||
|
this.vs = []interface{}{account}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfileAmountIndexKey struct {
|
||||||
|
vs []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x ProfileAmountIndexKey) id() uint32 { return 1 }
|
||||||
|
func (x ProfileAmountIndexKey) values() []interface{} { return x.vs }
|
||||||
|
func (x ProfileAmountIndexKey) profileIndexKey() {}
|
||||||
|
|
||||||
|
func (this ProfileAmountIndexKey) WithAmount(amount uint64) ProfileAmountIndexKey {
|
||||||
|
this.vs = []interface{}{amount}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
type profileTable struct {
|
||||||
|
table ormtable.Table
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) Insert(ctx context.Context, profile *Profile) error {
|
||||||
|
return this.table.Insert(ctx, profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) Update(ctx context.Context, profile *Profile) error {
|
||||||
|
return this.table.Update(ctx, profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) Save(ctx context.Context, profile *Profile) error {
|
||||||
|
return this.table.Save(ctx, profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) Delete(ctx context.Context, profile *Profile) error {
|
||||||
|
return this.table.Delete(ctx, profile)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) Has(ctx context.Context, account []byte) (found bool, err error) {
|
||||||
|
return this.table.PrimaryKey().Has(ctx, account)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) Get(ctx context.Context, account []byte) (*Profile, error) {
|
||||||
|
var profile Profile
|
||||||
|
found, err := this.table.PrimaryKey().Get(ctx, &profile, account)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, ormerrors.NotFound
|
||||||
|
}
|
||||||
|
return &profile, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) List(ctx context.Context, prefixKey ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) {
|
||||||
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
||||||
|
return ProfileIterator{it}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) ListRange(ctx context.Context, from, to ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) {
|
||||||
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
||||||
|
return ProfileIterator{it}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) DeleteBy(ctx context.Context, prefixKey ProfileIndexKey) error {
|
||||||
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) DeleteRange(ctx context.Context, from, to ProfileIndexKey) error {
|
||||||
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this profileTable) doNotImplement() {}
|
||||||
|
|
||||||
|
var _ ProfileTable = profileTable{}
|
||||||
|
|
||||||
|
func NewProfileTable(db ormtable.Schema) (ProfileTable, error) {
|
||||||
|
table := db.GetTable(&Profile{})
|
||||||
|
if table == nil {
|
||||||
|
return nil, ormerrors.TableNotFound.Wrap(string((&Profile{}).ProtoReflect().Descriptor().FullName()))
|
||||||
|
}
|
||||||
|
return profileTable{table}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type StateStore interface {
|
||||||
|
CredentialTable() CredentialTable
|
||||||
|
ProfileTable() ProfileTable
|
||||||
|
|
||||||
|
doNotImplement()
|
||||||
|
}
|
||||||
|
|
||||||
|
type stateStore struct {
|
||||||
|
credential CredentialTable
|
||||||
|
profile ProfileTable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x stateStore) CredentialTable() CredentialTable {
|
||||||
|
return x.credential
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x stateStore) ProfileTable() ProfileTable {
|
||||||
|
return x.profile
|
||||||
|
}
|
||||||
|
|
||||||
|
func (stateStore) doNotImplement() {}
|
||||||
|
|
||||||
|
var _ StateStore = stateStore{}
|
||||||
|
|
||||||
|
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
||||||
|
credentialTable, err := NewCredentialTable(db)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
profileTable, err := NewProfileTable(db)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateStore{
|
||||||
|
credentialTable,
|
||||||
|
profileTable,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
// - protoc (unknown)
|
// - protoc (unknown)
|
||||||
// source: macaroon/v1/tx.proto
|
// source: dwn/v1/tx.proto
|
||||||
|
|
||||||
package macaroonv1
|
package dwnv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
@@ -19,8 +19,8 @@ import (
|
|||||||
const _ = grpc.SupportPackageIsVersion9
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Msg_UpdateParams_FullMethodName = "/macaroon.v1.Msg/UpdateParams"
|
Msg_UpdateParams_FullMethodName = "/dwn.v1.Msg/UpdateParams"
|
||||||
Msg_IssueMacaroon_FullMethodName = "/macaroon.v1.Msg/IssueMacaroon"
|
Msg_Initialize_FullMethodName = "/dwn.v1.Msg/Initialize"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgClient is the client API for Msg service.
|
// MsgClient is the client API for Msg service.
|
||||||
@@ -33,9 +33,8 @@ type MsgClient interface {
|
|||||||
//
|
//
|
||||||
// Since: cosmos-sdk 0.47
|
// Since: cosmos-sdk 0.47
|
||||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
||||||
// IssueMacaroon asserts the given controller is the owner of the given
|
// Initialize spawns a new Vault
|
||||||
// address.
|
Initialize(ctx context.Context, in *MsgInitialize, opts ...grpc.CallOption) (*MsgInitializeResponse, error)
|
||||||
IssueMacaroon(ctx context.Context, in *MsgIssueMacaroon, opts ...grpc.CallOption) (*MsgIssueMacaroonResponse, error)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type msgClient struct {
|
type msgClient struct {
|
||||||
@@ -56,10 +55,10 @@ func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *msgClient) IssueMacaroon(ctx context.Context, in *MsgIssueMacaroon, opts ...grpc.CallOption) (*MsgIssueMacaroonResponse, error) {
|
func (c *msgClient) Initialize(ctx context.Context, in *MsgInitialize, opts ...grpc.CallOption) (*MsgInitializeResponse, error) {
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
||||||
out := new(MsgIssueMacaroonResponse)
|
out := new(MsgInitializeResponse)
|
||||||
err := c.cc.Invoke(ctx, Msg_IssueMacaroon_FullMethodName, in, out, cOpts...)
|
err := c.cc.Invoke(ctx, Msg_Initialize_FullMethodName, in, out, cOpts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -76,9 +75,8 @@ type MsgServer interface {
|
|||||||
//
|
//
|
||||||
// Since: cosmos-sdk 0.47
|
// Since: cosmos-sdk 0.47
|
||||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
||||||
// IssueMacaroon asserts the given controller is the owner of the given
|
// Initialize spawns a new Vault
|
||||||
// address.
|
Initialize(context.Context, *MsgInitialize) (*MsgInitializeResponse, error)
|
||||||
IssueMacaroon(context.Context, *MsgIssueMacaroon) (*MsgIssueMacaroonResponse, error)
|
|
||||||
mustEmbedUnimplementedMsgServer()
|
mustEmbedUnimplementedMsgServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,8 +90,8 @@ type UnimplementedMsgServer struct{}
|
|||||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedMsgServer) IssueMacaroon(context.Context, *MsgIssueMacaroon) (*MsgIssueMacaroonResponse, error) {
|
func (UnimplementedMsgServer) Initialize(context.Context, *MsgInitialize) (*MsgInitializeResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method IssueMacaroon not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Initialize not implemented")
|
||||||
}
|
}
|
||||||
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
||||||
func (UnimplementedMsgServer) testEmbeddedByValue() {}
|
func (UnimplementedMsgServer) testEmbeddedByValue() {}
|
||||||
@@ -134,20 +132,20 @@ func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(in
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func _Msg_IssueMacaroon_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
func _Msg_Initialize_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(MsgIssueMacaroon)
|
in := new(MsgInitialize)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if interceptor == nil {
|
if interceptor == nil {
|
||||||
return srv.(MsgServer).IssueMacaroon(ctx, in)
|
return srv.(MsgServer).Initialize(ctx, in)
|
||||||
}
|
}
|
||||||
info := &grpc.UnaryServerInfo{
|
info := &grpc.UnaryServerInfo{
|
||||||
Server: srv,
|
Server: srv,
|
||||||
FullMethod: Msg_IssueMacaroon_FullMethodName,
|
FullMethod: Msg_Initialize_FullMethodName,
|
||||||
}
|
}
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||||
return srv.(MsgServer).IssueMacaroon(ctx, req.(*MsgIssueMacaroon))
|
return srv.(MsgServer).Initialize(ctx, req.(*MsgInitialize))
|
||||||
}
|
}
|
||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
@@ -156,7 +154,7 @@ func _Msg_IssueMacaroon_Handler(srv interface{}, ctx context.Context, dec func(i
|
|||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
var Msg_ServiceDesc = grpc.ServiceDesc{
|
var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "macaroon.v1.Msg",
|
ServiceName: "dwn.v1.Msg",
|
||||||
HandlerType: (*MsgServer)(nil),
|
HandlerType: (*MsgServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
@@ -164,10 +162,10 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
|||||||
Handler: _Msg_UpdateParams_Handler,
|
Handler: _Msg_UpdateParams_Handler,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
MethodName: "IssueMacaroon",
|
MethodName: "Initialize",
|
||||||
Handler: _Msg_IssueMacaroon_Handler,
|
Handler: _Msg_Initialize_Handler,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "macaroon/v1/tx.proto",
|
Metadata: "dwn/v1/tx.proto",
|
||||||
}
|
}
|
||||||
@@ -1,506 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
|
||||||
package modulev1
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "cosmossdk.io/api/cosmos/app/v1alpha1"
|
|
||||||
fmt "fmt"
|
|
||||||
runtime "github.com/cosmos/cosmos-proto/runtime"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
io "io"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
md_Module protoreflect.MessageDescriptor
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
file_macaroon_module_v1_module_proto_init()
|
|
||||||
md_Module = File_macaroon_module_v1_module_proto.Messages().ByName("Module")
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
|
||||||
|
|
||||||
type fastReflection_Module Module
|
|
||||||
|
|
||||||
func (x *Module) ProtoReflect() protoreflect.Message {
|
|
||||||
return (*fastReflection_Module)(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Module) slowProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_macaroon_module_v1_module_proto_msgTypes[0]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _fastReflection_Module_messageType fastReflection_Module_messageType
|
|
||||||
var _ protoreflect.MessageType = fastReflection_Module_messageType{}
|
|
||||||
|
|
||||||
type fastReflection_Module_messageType struct{}
|
|
||||||
|
|
||||||
func (x fastReflection_Module_messageType) Zero() protoreflect.Message {
|
|
||||||
return (*fastReflection_Module)(nil)
|
|
||||||
}
|
|
||||||
func (x fastReflection_Module_messageType) New() protoreflect.Message {
|
|
||||||
return new(fastReflection_Module)
|
|
||||||
}
|
|
||||||
func (x fastReflection_Module_messageType) Descriptor() protoreflect.MessageDescriptor {
|
|
||||||
return md_Module
|
|
||||||
}
|
|
||||||
|
|
||||||
// Descriptor returns message descriptor, which contains only the protobuf
|
|
||||||
// type information for the message.
|
|
||||||
func (x *fastReflection_Module) Descriptor() protoreflect.MessageDescriptor {
|
|
||||||
return md_Module
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type returns the message type, which encapsulates both Go and protobuf
|
|
||||||
// type information. If the Go type information is not needed,
|
|
||||||
// it is recommended that the message descriptor be used instead.
|
|
||||||
func (x *fastReflection_Module) Type() protoreflect.MessageType {
|
|
||||||
return _fastReflection_Module_messageType
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a newly allocated and mutable empty message.
|
|
||||||
func (x *fastReflection_Module) New() protoreflect.Message {
|
|
||||||
return new(fastReflection_Module)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface unwraps the message reflection interface and
|
|
||||||
// returns the underlying ProtoMessage interface.
|
|
||||||
func (x *fastReflection_Module) Interface() protoreflect.ProtoMessage {
|
|
||||||
return (*Module)(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Range iterates over every populated field in an undefined order,
|
|
||||||
// calling f for each field descriptor and value encountered.
|
|
||||||
// Range returns immediately if f returns false.
|
|
||||||
// While iterating, mutating operations may only be performed
|
|
||||||
// on the current field descriptor.
|
|
||||||
func (x *fastReflection_Module) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Has reports whether a field is populated.
|
|
||||||
//
|
|
||||||
// Some fields have the property of nullability where it is possible to
|
|
||||||
// distinguish between the default value of a field and whether the field
|
|
||||||
// was explicitly populated with the default value. Singular message fields,
|
|
||||||
// member fields of a oneof, and proto2 scalar fields are nullable. Such
|
|
||||||
// fields are populated only if explicitly set.
|
|
||||||
//
|
|
||||||
// In other cases (aside from the nullable cases above),
|
|
||||||
// a proto3 scalar field is populated if it contains a non-zero value, and
|
|
||||||
// a repeated field is populated if it is non-empty.
|
|
||||||
func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
|
||||||
switch fd.FullName() {
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.macaroon.module.v1.Module"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message onsonr.sonr.macaroon.module.v1.Module does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear clears the field such that a subsequent Has call reports false.
|
|
||||||
//
|
|
||||||
// Clearing an extension field clears both the extension type and value
|
|
||||||
// associated with the given field number.
|
|
||||||
//
|
|
||||||
// Clear is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
|
||||||
switch fd.FullName() {
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.macaroon.module.v1.Module"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message onsonr.sonr.macaroon.module.v1.Module does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves the value for a field.
|
|
||||||
//
|
|
||||||
// For unpopulated scalars, it returns the default value, where
|
|
||||||
// the default value of a bytes scalar is guaranteed to be a copy.
|
|
||||||
// For unpopulated composite types, it returns an empty, read-only view
|
|
||||||
// of the value; to obtain a mutable reference, use Mutable.
|
|
||||||
func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
|
||||||
switch descriptor.FullName() {
|
|
||||||
default:
|
|
||||||
if descriptor.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.macaroon.module.v1.Module"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message onsonr.sonr.macaroon.module.v1.Module does not contain field %s", descriptor.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set stores the value for a field.
|
|
||||||
//
|
|
||||||
// For a field belonging to a oneof, it implicitly clears any other field
|
|
||||||
// that may be currently set within the same oneof.
|
|
||||||
// For extension fields, it implicitly stores the provided ExtensionType.
|
|
||||||
// When setting a composite type, it is unspecified whether the stored value
|
|
||||||
// aliases the source's memory in any way. If the composite value is an
|
|
||||||
// empty, read-only value, then it panics.
|
|
||||||
//
|
|
||||||
// Set is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
|
||||||
switch fd.FullName() {
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.macaroon.module.v1.Module"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message onsonr.sonr.macaroon.module.v1.Module does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mutable returns a mutable reference to a composite type.
|
|
||||||
//
|
|
||||||
// If the field is unpopulated, it may allocate a composite value.
|
|
||||||
// For a field belonging to a oneof, it implicitly clears any other field
|
|
||||||
// that may be currently set within the same oneof.
|
|
||||||
// For extension fields, it implicitly stores the provided ExtensionType
|
|
||||||
// if not already stored.
|
|
||||||
// It panics if the field does not contain a composite type.
|
|
||||||
//
|
|
||||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
|
||||||
switch fd.FullName() {
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.macaroon.module.v1.Module"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message onsonr.sonr.macaroon.module.v1.Module does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewField returns a new value that is assignable to the field
|
|
||||||
// for the given descriptor. For scalars, this returns the default value.
|
|
||||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
|
||||||
func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
|
||||||
switch fd.FullName() {
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.macaroon.module.v1.Module"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message onsonr.sonr.macaroon.module.v1.Module does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WhichOneof reports which field within the oneof is populated,
|
|
||||||
// returning nil if none are populated.
|
|
||||||
// It panics if the oneof descriptor does not belong to this message.
|
|
||||||
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
|
||||||
switch d.FullName() {
|
|
||||||
default:
|
|
||||||
panic(fmt.Errorf("%s is not a oneof field in onsonr.sonr.macaroon.module.v1.Module", d.FullName()))
|
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUnknown retrieves the entire list of unknown fields.
|
|
||||||
// The caller may only mutate the contents of the RawFields
|
|
||||||
// if the mutated bytes are stored back into the message with SetUnknown.
|
|
||||||
func (x *fastReflection_Module) GetUnknown() protoreflect.RawFields {
|
|
||||||
return x.unknownFields
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUnknown stores an entire list of unknown fields.
|
|
||||||
// The raw fields must be syntactically valid according to the wire format.
|
|
||||||
// An implementation may panic if this is not the case.
|
|
||||||
// Once stored, the caller must not mutate the content of the RawFields.
|
|
||||||
// An empty RawFields may be passed to clear the fields.
|
|
||||||
//
|
|
||||||
// SetUnknown is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_Module) SetUnknown(fields protoreflect.RawFields) {
|
|
||||||
x.unknownFields = fields
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValid reports whether the message is valid.
|
|
||||||
//
|
|
||||||
// An invalid message is an empty, read-only value.
|
|
||||||
//
|
|
||||||
// An invalid message often corresponds to a nil pointer of the concrete
|
|
||||||
// message type, but the details are implementation dependent.
|
|
||||||
// Validity is not part of the protobuf data model, and may not
|
|
||||||
// be preserved in marshaling or other operations.
|
|
||||||
func (x *fastReflection_Module) IsValid() bool {
|
|
||||||
return x != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations.
|
|
||||||
// This method may return nil.
|
|
||||||
//
|
|
||||||
// The returned methods type is identical to
|
|
||||||
// "google.golang.org/protobuf/runtime/protoiface".Methods.
|
|
||||||
// Consult the protoiface package documentation for details.
|
|
||||||
func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
|
||||||
size := func(input protoiface.SizeInput) protoiface.SizeOutput {
|
|
||||||
x := input.Message.Interface().(*Module)
|
|
||||||
if x == nil {
|
|
||||||
return protoiface.SizeOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Size: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options := runtime.SizeInputToOptions(input)
|
|
||||||
_ = options
|
|
||||||
var n int
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
if x.unknownFields != nil {
|
|
||||||
n += len(x.unknownFields)
|
|
||||||
}
|
|
||||||
return protoiface.SizeOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Size: n,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) {
|
|
||||||
x := input.Message.Interface().(*Module)
|
|
||||||
if x == nil {
|
|
||||||
return protoiface.MarshalOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Buf: input.Buf,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
options := runtime.MarshalInputToOptions(input)
|
|
||||||
_ = options
|
|
||||||
size := options.Size(x)
|
|
||||||
dAtA := make([]byte, size)
|
|
||||||
i := len(dAtA)
|
|
||||||
_ = i
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
if x.unknownFields != nil {
|
|
||||||
i -= len(x.unknownFields)
|
|
||||||
copy(dAtA[i:], x.unknownFields)
|
|
||||||
}
|
|
||||||
if input.Buf != nil {
|
|
||||||
input.Buf = append(input.Buf, dAtA...)
|
|
||||||
} else {
|
|
||||||
input.Buf = dAtA
|
|
||||||
}
|
|
||||||
return protoiface.MarshalOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Buf: input.Buf,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) {
|
|
||||||
x := input.Message.Interface().(*Module)
|
|
||||||
if x == nil {
|
|
||||||
return protoiface.UnmarshalOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Flags: input.Flags,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
options := runtime.UnmarshalInputToOptions(input)
|
|
||||||
_ = options
|
|
||||||
dAtA := input.Buf
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
preIndex := iNdEx
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldNum := int32(wire >> 3)
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
if wireType == 4 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: wiretype end group for non-group")
|
|
||||||
}
|
|
||||||
if fieldNum <= 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Module: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
||||||
}
|
|
||||||
switch fieldNum {
|
|
||||||
default:
|
|
||||||
iNdEx = preIndex
|
|
||||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
|
||||||
if err != nil {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
|
|
||||||
}
|
|
||||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
if (iNdEx + skippy) > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if !options.DiscardUnknown {
|
|
||||||
x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)
|
|
||||||
}
|
|
||||||
iNdEx += skippy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if iNdEx > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil
|
|
||||||
}
|
|
||||||
return &protoiface.Methods{
|
|
||||||
NoUnkeyedLiterals: struct{}{},
|
|
||||||
Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown,
|
|
||||||
Size: size,
|
|
||||||
Marshal: marshal,
|
|
||||||
Unmarshal: unmarshal,
|
|
||||||
Merge: nil,
|
|
||||||
CheckInitialized: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.27.0
|
|
||||||
// protoc (unknown)
|
|
||||||
// source: macaroon/module/v1/module.proto
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Module is the app config object of the module.
|
|
||||||
// Learn more: https://docs.cosmos.network/main/building-modules/depinject
|
|
||||||
type Module struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Module) Reset() {
|
|
||||||
*x = Module{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_macaroon_module_v1_module_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *Module) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*Module) ProtoMessage() {}
|
|
||||||
|
|
||||||
// Deprecated: Use Module.ProtoReflect.Descriptor instead.
|
|
||||||
func (*Module) Descriptor() ([]byte, []int) {
|
|
||||||
return file_macaroon_module_v1_module_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_macaroon_module_v1_module_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_macaroon_module_v1_module_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x1f, 0x6d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c,
|
|
||||||
0x65, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
|
||||||
0x6f, 0x12, 0x1e, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x6d,
|
|
||||||
0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76,
|
|
||||||
0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31,
|
|
||||||
0x61, 0x6c, 0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72,
|
|
||||||
0x6f, 0x74, 0x6f, 0x22, 0x33, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x29, 0xba,
|
|
||||||
0xc0, 0x96, 0xda, 0x01, 0x23, 0x0a, 0x21, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
|
||||||
0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x78, 0x2f,
|
|
||||||
0x6d, 0x61, 0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x42, 0x86, 0x02, 0x0a, 0x22, 0x63, 0x6f, 0x6d,
|
|
||||||
0x2e, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x6d, 0x61, 0x63,
|
|
||||||
0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42,
|
|
||||||
0x0b, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x36,
|
|
||||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e,
|
|
||||||
0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x6d, 0x61, 0x63, 0x61, 0x72,
|
|
||||||
0x6f, 0x6f, 0x6e, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f,
|
|
||||||
0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x04, 0x4f, 0x53, 0x4d, 0x4d, 0xaa, 0x02, 0x1e,
|
|
||||||
0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x53, 0x6f, 0x6e, 0x72, 0x2e, 0x4d, 0x61, 0x63, 0x61,
|
|
||||||
0x72, 0x6f, 0x6f, 0x6e, 0x2e, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02,
|
|
||||||
0x1e, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x4d, 0x61, 0x63,
|
|
||||||
0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2,
|
|
||||||
0x02, 0x2a, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x4d, 0x61,
|
|
||||||
0x63, 0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x5c, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31,
|
|
||||||
0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x22, 0x4f,
|
|
||||||
0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x53, 0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x4d, 0x61, 0x63,
|
|
||||||
0x61, 0x72, 0x6f, 0x6f, 0x6e, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56,
|
|
||||||
0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_macaroon_module_v1_module_proto_rawDescOnce sync.Once
|
|
||||||
file_macaroon_module_v1_module_proto_rawDescData = file_macaroon_module_v1_module_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_macaroon_module_v1_module_proto_rawDescGZIP() []byte {
|
|
||||||
file_macaroon_module_v1_module_proto_rawDescOnce.Do(func() {
|
|
||||||
file_macaroon_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_macaroon_module_v1_module_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_macaroon_module_v1_module_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_macaroon_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
|
||||||
var file_macaroon_module_v1_module_proto_goTypes = []interface{}{
|
|
||||||
(*Module)(nil), // 0: onsonr.sonr.macaroon.module.v1.Module
|
|
||||||
}
|
|
||||||
var file_macaroon_module_v1_module_proto_depIdxs = []int32{
|
|
||||||
0, // [0:0] is the sub-list for method output_type
|
|
||||||
0, // [0:0] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_macaroon_module_v1_module_proto_init() }
|
|
||||||
func file_macaroon_module_v1_module_proto_init() {
|
|
||||||
if File_macaroon_module_v1_module_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_macaroon_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*Module); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_macaroon_module_v1_module_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 1,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_macaroon_module_v1_module_proto_goTypes,
|
|
||||||
DependencyIndexes: file_macaroon_module_v1_module_proto_depIdxs,
|
|
||||||
MessageInfos: file_macaroon_module_v1_module_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_macaroon_module_v1_module_proto = out.File
|
|
||||||
file_macaroon_module_v1_module_proto_rawDesc = nil
|
|
||||||
file_macaroon_module_v1_module_proto_goTypes = nil
|
|
||||||
file_macaroon_module_v1_module_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,207 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
|
||||||
// - protoc (unknown)
|
|
||||||
// source: macaroon/v1/query.proto
|
|
||||||
|
|
||||||
package macaroonv1
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
Query_Params_FullMethodName = "/macaroon.v1.Query/Params"
|
|
||||||
Query_RefreshToken_FullMethodName = "/macaroon.v1.Query/RefreshToken"
|
|
||||||
Query_ValidateToken_FullMethodName = "/macaroon.v1.Query/ValidateToken"
|
|
||||||
)
|
|
||||||
|
|
||||||
// QueryClient is the client API for Query service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
//
|
|
||||||
// Query provides defines the gRPC querier service.
|
|
||||||
type QueryClient interface {
|
|
||||||
// Params queries all parameters of the module.
|
|
||||||
Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error)
|
|
||||||
// RefreshToken refreshes a macaroon token as post authentication.
|
|
||||||
RefreshToken(ctx context.Context, in *QueryRefreshTokenRequest, opts ...grpc.CallOption) (*QueryRefreshTokenResponse, error)
|
|
||||||
// ValidateToken validates a macaroon token as pre authentication.
|
|
||||||
ValidateToken(ctx context.Context, in *QueryValidateTokenRequest, opts ...grpc.CallOption) (*QueryValidateTokenResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type queryClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewQueryClient(cc grpc.ClientConnInterface) QueryClient {
|
|
||||||
return &queryClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(QueryParamsResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Query_Params_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *queryClient) RefreshToken(ctx context.Context, in *QueryRefreshTokenRequest, opts ...grpc.CallOption) (*QueryRefreshTokenResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(QueryRefreshTokenResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Query_RefreshToken_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *queryClient) ValidateToken(ctx context.Context, in *QueryValidateTokenRequest, opts ...grpc.CallOption) (*QueryValidateTokenResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(QueryValidateTokenResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Query_ValidateToken_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// QueryServer is the server API for Query service.
|
|
||||||
// All implementations must embed UnimplementedQueryServer
|
|
||||||
// for forward compatibility.
|
|
||||||
//
|
|
||||||
// Query provides defines the gRPC querier service.
|
|
||||||
type QueryServer interface {
|
|
||||||
// Params queries all parameters of the module.
|
|
||||||
Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error)
|
|
||||||
// RefreshToken refreshes a macaroon token as post authentication.
|
|
||||||
RefreshToken(context.Context, *QueryRefreshTokenRequest) (*QueryRefreshTokenResponse, error)
|
|
||||||
// ValidateToken validates a macaroon token as pre authentication.
|
|
||||||
ValidateToken(context.Context, *QueryValidateTokenRequest) (*QueryValidateTokenResponse, error)
|
|
||||||
mustEmbedUnimplementedQueryServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedQueryServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedQueryServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedQueryServer) Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Params not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedQueryServer) RefreshToken(context.Context, *QueryRefreshTokenRequest) (*QueryRefreshTokenResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method RefreshToken not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedQueryServer) ValidateToken(context.Context, *QueryValidateTokenRequest) (*QueryValidateTokenResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method ValidateToken not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedQueryServer) mustEmbedUnimplementedQueryServer() {}
|
|
||||||
func (UnimplementedQueryServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeQueryServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to QueryServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeQueryServer interface {
|
|
||||||
mustEmbedUnimplementedQueryServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterQueryServer(s grpc.ServiceRegistrar, srv QueryServer) {
|
|
||||||
// If the following call pancis, it indicates UnimplementedQueryServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&Query_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(QueryParamsRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(QueryServer).Params(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Query_Params_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Query_RefreshToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(QueryRefreshTokenRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(QueryServer).RefreshToken(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Query_RefreshToken_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(QueryServer).RefreshToken(ctx, req.(*QueryRefreshTokenRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Query_ValidateToken_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(QueryValidateTokenRequest)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(QueryServer).ValidateToken(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Query_ValidateToken_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(QueryServer).ValidateToken(ctx, req.(*QueryValidateTokenRequest))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query_ServiceDesc is the grpc.ServiceDesc for Query service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var Query_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "macaroon.v1.Query",
|
|
||||||
HandlerType: (*QueryServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "Params",
|
|
||||||
Handler: _Query_Params_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "RefreshToken",
|
|
||||||
Handler: _Query_RefreshToken_Handler,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
MethodName: "ValidateToken",
|
|
||||||
Handler: _Query_ValidateToken_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "macaroon/v1/query.proto",
|
|
||||||
}
|
|
||||||
@@ -1,385 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
|
||||||
|
|
||||||
package macaroonv1
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
ormlist "cosmossdk.io/orm/model/ormlist"
|
|
||||||
ormtable "cosmossdk.io/orm/model/ormtable"
|
|
||||||
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type GrantTable interface {
|
|
||||||
Insert(ctx context.Context, grant *Grant) error
|
|
||||||
InsertReturningId(ctx context.Context, grant *Grant) (uint64, error)
|
|
||||||
LastInsertedSequence(ctx context.Context) (uint64, error)
|
|
||||||
Update(ctx context.Context, grant *Grant) error
|
|
||||||
Save(ctx context.Context, grant *Grant) error
|
|
||||||
Delete(ctx context.Context, grant *Grant) error
|
|
||||||
Has(ctx context.Context, id uint64) (found bool, err error)
|
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
Get(ctx context.Context, id uint64) (*Grant, error)
|
|
||||||
HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error)
|
|
||||||
// GetBySubjectOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Grant, error)
|
|
||||||
List(ctx context.Context, prefixKey GrantIndexKey, opts ...ormlist.Option) (GrantIterator, error)
|
|
||||||
ListRange(ctx context.Context, from, to GrantIndexKey, opts ...ormlist.Option) (GrantIterator, error)
|
|
||||||
DeleteBy(ctx context.Context, prefixKey GrantIndexKey) error
|
|
||||||
DeleteRange(ctx context.Context, from, to GrantIndexKey) error
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type GrantIterator struct {
|
|
||||||
ormtable.Iterator
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i GrantIterator) Value() (*Grant, error) {
|
|
||||||
var grant Grant
|
|
||||||
err := i.UnmarshalMessage(&grant)
|
|
||||||
return &grant, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type GrantIndexKey interface {
|
|
||||||
id() uint32
|
|
||||||
values() []interface{}
|
|
||||||
grantIndexKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
// primary key starting index..
|
|
||||||
type GrantPrimaryKey = GrantIdIndexKey
|
|
||||||
|
|
||||||
type GrantIdIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x GrantIdIndexKey) id() uint32 { return 0 }
|
|
||||||
func (x GrantIdIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x GrantIdIndexKey) grantIndexKey() {}
|
|
||||||
|
|
||||||
func (this GrantIdIndexKey) WithId(id uint64) GrantIdIndexKey {
|
|
||||||
this.vs = []interface{}{id}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type GrantSubjectOriginIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x GrantSubjectOriginIndexKey) id() uint32 { return 1 }
|
|
||||||
func (x GrantSubjectOriginIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x GrantSubjectOriginIndexKey) grantIndexKey() {}
|
|
||||||
|
|
||||||
func (this GrantSubjectOriginIndexKey) WithSubject(subject string) GrantSubjectOriginIndexKey {
|
|
||||||
this.vs = []interface{}{subject}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this GrantSubjectOriginIndexKey) WithSubjectOrigin(subject string, origin string) GrantSubjectOriginIndexKey {
|
|
||||||
this.vs = []interface{}{subject, origin}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type grantTable struct {
|
|
||||||
table ormtable.AutoIncrementTable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) Insert(ctx context.Context, grant *Grant) error {
|
|
||||||
return this.table.Insert(ctx, grant)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) Update(ctx context.Context, grant *Grant) error {
|
|
||||||
return this.table.Update(ctx, grant)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) Save(ctx context.Context, grant *Grant) error {
|
|
||||||
return this.table.Save(ctx, grant)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) Delete(ctx context.Context, grant *Grant) error {
|
|
||||||
return this.table.Delete(ctx, grant)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) InsertReturningId(ctx context.Context, grant *Grant) (uint64, error) {
|
|
||||||
return this.table.InsertReturningPKey(ctx, grant)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
|
||||||
return this.table.LastInsertedSequence(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) Has(ctx context.Context, id uint64) (found bool, err error) {
|
|
||||||
return this.table.PrimaryKey().Has(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) Get(ctx context.Context, id uint64) (*Grant, error) {
|
|
||||||
var grant Grant
|
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &grant, id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &grant, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error) {
|
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
|
||||||
subject,
|
|
||||||
origin,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Grant, error) {
|
|
||||||
var grant Grant
|
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &grant,
|
|
||||||
subject,
|
|
||||||
origin,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &grant, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) List(ctx context.Context, prefixKey GrantIndexKey, opts ...ormlist.Option) (GrantIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
|
||||||
return GrantIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) ListRange(ctx context.Context, from, to GrantIndexKey, opts ...ormlist.Option) (GrantIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
|
||||||
return GrantIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) DeleteBy(ctx context.Context, prefixKey GrantIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) DeleteRange(ctx context.Context, from, to GrantIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this grantTable) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ GrantTable = grantTable{}
|
|
||||||
|
|
||||||
func NewGrantTable(db ormtable.Schema) (GrantTable, error) {
|
|
||||||
table := db.GetTable(&Grant{})
|
|
||||||
if table == nil {
|
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Grant{}).ProtoReflect().Descriptor().FullName()))
|
|
||||||
}
|
|
||||||
return grantTable{table.(ormtable.AutoIncrementTable)}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type MacaroonTable interface {
|
|
||||||
Insert(ctx context.Context, macaroon *Macaroon) error
|
|
||||||
InsertReturningId(ctx context.Context, macaroon *Macaroon) (uint64, error)
|
|
||||||
LastInsertedSequence(ctx context.Context) (uint64, error)
|
|
||||||
Update(ctx context.Context, macaroon *Macaroon) error
|
|
||||||
Save(ctx context.Context, macaroon *Macaroon) error
|
|
||||||
Delete(ctx context.Context, macaroon *Macaroon) error
|
|
||||||
Has(ctx context.Context, id uint64) (found bool, err error)
|
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
Get(ctx context.Context, id uint64) (*Macaroon, error)
|
|
||||||
HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error)
|
|
||||||
// GetBySubjectOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Macaroon, error)
|
|
||||||
List(ctx context.Context, prefixKey MacaroonIndexKey, opts ...ormlist.Option) (MacaroonIterator, error)
|
|
||||||
ListRange(ctx context.Context, from, to MacaroonIndexKey, opts ...ormlist.Option) (MacaroonIterator, error)
|
|
||||||
DeleteBy(ctx context.Context, prefixKey MacaroonIndexKey) error
|
|
||||||
DeleteRange(ctx context.Context, from, to MacaroonIndexKey) error
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type MacaroonIterator struct {
|
|
||||||
ormtable.Iterator
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i MacaroonIterator) Value() (*Macaroon, error) {
|
|
||||||
var macaroon Macaroon
|
|
||||||
err := i.UnmarshalMessage(&macaroon)
|
|
||||||
return &macaroon, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type MacaroonIndexKey interface {
|
|
||||||
id() uint32
|
|
||||||
values() []interface{}
|
|
||||||
macaroonIndexKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
// primary key starting index..
|
|
||||||
type MacaroonPrimaryKey = MacaroonIdIndexKey
|
|
||||||
|
|
||||||
type MacaroonIdIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x MacaroonIdIndexKey) id() uint32 { return 0 }
|
|
||||||
func (x MacaroonIdIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x MacaroonIdIndexKey) macaroonIndexKey() {}
|
|
||||||
|
|
||||||
func (this MacaroonIdIndexKey) WithId(id uint64) MacaroonIdIndexKey {
|
|
||||||
this.vs = []interface{}{id}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type MacaroonSubjectOriginIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x MacaroonSubjectOriginIndexKey) id() uint32 { return 1 }
|
|
||||||
func (x MacaroonSubjectOriginIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x MacaroonSubjectOriginIndexKey) macaroonIndexKey() {}
|
|
||||||
|
|
||||||
func (this MacaroonSubjectOriginIndexKey) WithSubject(subject string) MacaroonSubjectOriginIndexKey {
|
|
||||||
this.vs = []interface{}{subject}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this MacaroonSubjectOriginIndexKey) WithSubjectOrigin(subject string, origin string) MacaroonSubjectOriginIndexKey {
|
|
||||||
this.vs = []interface{}{subject, origin}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type macaroonTable struct {
|
|
||||||
table ormtable.AutoIncrementTable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) Insert(ctx context.Context, macaroon *Macaroon) error {
|
|
||||||
return this.table.Insert(ctx, macaroon)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) Update(ctx context.Context, macaroon *Macaroon) error {
|
|
||||||
return this.table.Update(ctx, macaroon)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) Save(ctx context.Context, macaroon *Macaroon) error {
|
|
||||||
return this.table.Save(ctx, macaroon)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) Delete(ctx context.Context, macaroon *Macaroon) error {
|
|
||||||
return this.table.Delete(ctx, macaroon)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) InsertReturningId(ctx context.Context, macaroon *Macaroon) (uint64, error) {
|
|
||||||
return this.table.InsertReturningPKey(ctx, macaroon)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
|
||||||
return this.table.LastInsertedSequence(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) Has(ctx context.Context, id uint64) (found bool, err error) {
|
|
||||||
return this.table.PrimaryKey().Has(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) Get(ctx context.Context, id uint64) (*Macaroon, error) {
|
|
||||||
var macaroon Macaroon
|
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &macaroon, id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &macaroon, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error) {
|
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
|
||||||
subject,
|
|
||||||
origin,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Macaroon, error) {
|
|
||||||
var macaroon Macaroon
|
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &macaroon,
|
|
||||||
subject,
|
|
||||||
origin,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &macaroon, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) List(ctx context.Context, prefixKey MacaroonIndexKey, opts ...ormlist.Option) (MacaroonIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
|
||||||
return MacaroonIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) ListRange(ctx context.Context, from, to MacaroonIndexKey, opts ...ormlist.Option) (MacaroonIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
|
||||||
return MacaroonIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) DeleteBy(ctx context.Context, prefixKey MacaroonIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) DeleteRange(ctx context.Context, from, to MacaroonIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this macaroonTable) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ MacaroonTable = macaroonTable{}
|
|
||||||
|
|
||||||
func NewMacaroonTable(db ormtable.Schema) (MacaroonTable, error) {
|
|
||||||
table := db.GetTable(&Macaroon{})
|
|
||||||
if table == nil {
|
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Macaroon{}).ProtoReflect().Descriptor().FullName()))
|
|
||||||
}
|
|
||||||
return macaroonTable{table.(ormtable.AutoIncrementTable)}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type StateStore interface {
|
|
||||||
GrantTable() GrantTable
|
|
||||||
MacaroonTable() MacaroonTable
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type stateStore struct {
|
|
||||||
grant GrantTable
|
|
||||||
macaroon MacaroonTable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x stateStore) GrantTable() GrantTable {
|
|
||||||
return x.grant
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x stateStore) MacaroonTable() MacaroonTable {
|
|
||||||
return x.macaroon
|
|
||||||
}
|
|
||||||
|
|
||||||
func (stateStore) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ StateStore = stateStore{}
|
|
||||||
|
|
||||||
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
|
||||||
grantTable, err := NewGrantTable(db)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
macaroonTable, err := NewMacaroonTable(db)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return stateStore{
|
|
||||||
grantTable,
|
|
||||||
macaroonTable,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -18,8 +18,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_module_v1_module_proto_init()
|
file_svc_module_v1_module_proto_init()
|
||||||
md_Module = File_service_module_v1_module_proto.Messages().ByName("Module")
|
md_Module = File_svc_module_v1_module_proto.Messages().ByName("Module")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
var _ protoreflect.Message = (*fastReflection_Module)(nil)
|
||||||
@@ -31,7 +31,7 @@ func (x *Module) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *Module) slowProtoReflect() protoreflect.Message {
|
func (x *Module) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_module_v1_module_proto_msgTypes[0]
|
mi := &file_svc_module_v1_module_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -104,9 +104,9 @@ func (x *fastReflection_Module) Has(fd protoreflect.FieldDescriptor) bool {
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.service.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.service.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,9 +120,9 @@ func (x *fastReflection_Module) Clear(fd protoreflect.FieldDescriptor) {
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.service.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.service.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +136,9 @@ func (x *fastReflection_Module) Get(descriptor protoreflect.FieldDescriptor) pro
|
|||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.service.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.service.module.v1.Module does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.module.v1.Module does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +156,9 @@ func (x *fastReflection_Module) Set(fd protoreflect.FieldDescriptor, value proto
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.service.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.service.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ func (x *fastReflection_Module) Mutable(fd protoreflect.FieldDescriptor) protore
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.service.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.service.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +189,9 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: onsonr.sonr.service.module.v1.Module"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.module.v1.Module"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message onsonr.sonr.service.module.v1.Module does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.module.v1.Module does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ func (x *fastReflection_Module) NewField(fd protoreflect.FieldDescriptor) protor
|
|||||||
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_Module) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in onsonr.sonr.service.module.v1.Module", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.module.v1.Module", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -373,7 +373,7 @@ func (x *fastReflection_Module) ProtoMethods() *protoiface.Methods {
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.27.0
|
// protoc-gen-go v1.27.0
|
||||||
// protoc (unknown)
|
// protoc (unknown)
|
||||||
// source: service/module/v1/module.proto
|
// source: svc/module/v1/module.proto
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
@@ -393,7 +393,7 @@ type Module struct {
|
|||||||
func (x *Module) Reset() {
|
func (x *Module) Reset() {
|
||||||
*x = Module{}
|
*x = Module{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_module_v1_module_proto_msgTypes[0]
|
mi := &file_svc_module_v1_module_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -407,57 +407,50 @@ func (*Module) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use Module.ProtoReflect.Descriptor instead.
|
// Deprecated: Use Module.ProtoReflect.Descriptor instead.
|
||||||
func (*Module) Descriptor() ([]byte, []int) {
|
func (*Module) Descriptor() ([]byte, []int) {
|
||||||
return file_service_module_v1_module_proto_rawDescGZIP(), []int{0}
|
return file_svc_module_v1_module_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_service_module_v1_module_proto protoreflect.FileDescriptor
|
var File_svc_module_v1_module_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_service_module_v1_module_proto_rawDesc = []byte{
|
var file_svc_module_v1_module_proto_rawDesc = []byte{
|
||||||
0x0a, 0x1e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
|
0x0a, 0x1a, 0x73, 0x76, 0x63, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f,
|
||||||
0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0d, 0x73, 0x76,
|
||||||
0x12, 0x1d, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x65,
|
0x63, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x20, 0x63, 0x6f, 0x73,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a,
|
0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c, 0x70, 0x68, 0x61, 0x31,
|
||||||
0x20, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x61, 0x70, 0x70, 0x2f, 0x76, 0x31, 0x61, 0x6c,
|
0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x28, 0x0a,
|
||||||
0x70, 0x68, 0x61, 0x31, 0x2f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x1e, 0xba, 0xc0, 0x96, 0xda, 0x01, 0x18, 0x0a,
|
||||||
0x6f, 0x22, 0x32, 0x0a, 0x06, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a, 0x28, 0xba, 0xc0, 0x96,
|
0x16, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f,
|
||||||
0xda, 0x01, 0x22, 0x0a, 0x20, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x42, 0xa9, 0x01, 0x0a, 0x11, 0x63, 0x6f, 0x6d, 0x2e,
|
||||||
0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x78, 0x2f, 0x73, 0x65,
|
0x73, 0x76, 0x63, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x42, 0x80, 0x02, 0x0a, 0x21, 0x63, 0x6f, 0x6d, 0x2e, 0x6f, 0x6e,
|
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x31, 0x67, 0x69,
|
||||||
0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x6f, 0x6e, 0x72, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f,
|
||||||
0x65, 0x2e, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0b, 0x4d, 0x6f, 0x64,
|
0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x76, 0x63, 0x2f, 0x6d, 0x6f, 0x64,
|
||||||
0x75, 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x35, 0x67, 0x69, 0x74, 0x68,
|
0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76, 0x31, 0xa2,
|
||||||
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f,
|
0x02, 0x03, 0x53, 0x4d, 0x58, 0xaa, 0x02, 0x0d, 0x53, 0x76, 0x63, 0x2e, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x6d,
|
0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0d, 0x53, 0x76, 0x63, 0x5c, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x76,
|
0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x19, 0x53, 0x76, 0x63, 0x5c, 0x4d, 0x6f, 0x64, 0x75,
|
||||||
0x31, 0xa2, 0x02, 0x04, 0x4f, 0x53, 0x53, 0x4d, 0xaa, 0x02, 0x1d, 0x4f, 0x6e, 0x73, 0x6f, 0x6e,
|
0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
|
||||||
0x72, 0x2e, 0x53, 0x6f, 0x6e, 0x72, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x4d,
|
0x61, 0xea, 0x02, 0x0f, 0x53, 0x76, 0x63, 0x3a, 0x3a, 0x4d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x3a,
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x1d, 0x4f, 0x6e, 0x73, 0x6f, 0x6e,
|
0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5c, 0x4d,
|
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x29, 0x4f, 0x6e, 0x73, 0x6f, 0x6e,
|
|
||||||
0x72, 0x5c, 0x53, 0x6f, 0x6e, 0x72, 0x5c, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5c, 0x4d,
|
|
||||||
0x6f, 0x64, 0x75, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61,
|
|
||||||
0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x21, 0x4f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x53,
|
|
||||||
0x6f, 0x6e, 0x72, 0x3a, 0x3a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x3a, 0x3a, 0x4d, 0x6f,
|
|
||||||
0x64, 0x75, 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_service_module_v1_module_proto_rawDescOnce sync.Once
|
file_svc_module_v1_module_proto_rawDescOnce sync.Once
|
||||||
file_service_module_v1_module_proto_rawDescData = file_service_module_v1_module_proto_rawDesc
|
file_svc_module_v1_module_proto_rawDescData = file_svc_module_v1_module_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_service_module_v1_module_proto_rawDescGZIP() []byte {
|
func file_svc_module_v1_module_proto_rawDescGZIP() []byte {
|
||||||
file_service_module_v1_module_proto_rawDescOnce.Do(func() {
|
file_svc_module_v1_module_proto_rawDescOnce.Do(func() {
|
||||||
file_service_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_module_v1_module_proto_rawDescData)
|
file_svc_module_v1_module_proto_rawDescData = protoimpl.X.CompressGZIP(file_svc_module_v1_module_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_service_module_v1_module_proto_rawDescData
|
return file_svc_module_v1_module_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_service_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
var file_svc_module_v1_module_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||||
var file_service_module_v1_module_proto_goTypes = []interface{}{
|
var file_svc_module_v1_module_proto_goTypes = []interface{}{
|
||||||
(*Module)(nil), // 0: onsonr.sonr.service.module.v1.Module
|
(*Module)(nil), // 0: svc.module.v1.Module
|
||||||
}
|
}
|
||||||
var file_service_module_v1_module_proto_depIdxs = []int32{
|
var file_svc_module_v1_module_proto_depIdxs = []int32{
|
||||||
0, // [0:0] is the sub-list for method output_type
|
0, // [0:0] is the sub-list for method output_type
|
||||||
0, // [0:0] is the sub-list for method input_type
|
0, // [0:0] is the sub-list for method input_type
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
0, // [0:0] is the sub-list for extension type_name
|
||||||
@@ -465,13 +458,13 @@ var file_service_module_v1_module_proto_depIdxs = []int32{
|
|||||||
0, // [0:0] is the sub-list for field type_name
|
0, // [0:0] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_service_module_v1_module_proto_init() }
|
func init() { file_svc_module_v1_module_proto_init() }
|
||||||
func file_service_module_v1_module_proto_init() {
|
func file_svc_module_v1_module_proto_init() {
|
||||||
if File_service_module_v1_module_proto != nil {
|
if File_svc_module_v1_module_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_service_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_module_v1_module_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*Module); i {
|
switch v := v.(*Module); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -488,18 +481,18 @@ func file_service_module_v1_module_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_service_module_v1_module_proto_rawDesc,
|
RawDescriptor: file_svc_module_v1_module_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 1,
|
NumMessages: 1,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 0,
|
NumServices: 0,
|
||||||
},
|
},
|
||||||
GoTypes: file_service_module_v1_module_proto_goTypes,
|
GoTypes: file_svc_module_v1_module_proto_goTypes,
|
||||||
DependencyIndexes: file_service_module_v1_module_proto_depIdxs,
|
DependencyIndexes: file_svc_module_v1_module_proto_depIdxs,
|
||||||
MessageInfos: file_service_module_v1_module_proto_msgTypes,
|
MessageInfos: file_svc_module_v1_module_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_service_module_v1_module_proto = out.File
|
File_svc_module_v1_module_proto = out.File
|
||||||
file_service_module_v1_module_proto_rawDesc = nil
|
file_svc_module_v1_module_proto_rawDesc = nil
|
||||||
file_service_module_v1_module_proto_goTypes = nil
|
file_svc_module_v1_module_proto_goTypes = nil
|
||||||
file_service_module_v1_module_proto_depIdxs = nil
|
file_svc_module_v1_module_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
||||||
package servicev1
|
package svcv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
@@ -18,8 +18,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_v1_query_proto_init()
|
file_svc_v1_query_proto_init()
|
||||||
md_QueryParamsRequest = File_service_v1_query_proto.Messages().ByName("QueryParamsRequest")
|
md_QueryParamsRequest = File_svc_v1_query_proto.Messages().ByName("QueryParamsRequest")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ protoreflect.Message = (*fastReflection_QueryParamsRequest)(nil)
|
var _ protoreflect.Message = (*fastReflection_QueryParamsRequest)(nil)
|
||||||
@@ -31,7 +31,7 @@ func (x *QueryParamsRequest) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *QueryParamsRequest) slowProtoReflect() protoreflect.Message {
|
func (x *QueryParamsRequest) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_v1_query_proto_msgTypes[0]
|
mi := &file_svc_v1_query_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -104,9 +104,9 @@ func (x *fastReflection_QueryParamsRequest) Has(fd protoreflect.FieldDescriptor)
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsRequest"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsRequest"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,9 +120,9 @@ func (x *fastReflection_QueryParamsRequest) Clear(fd protoreflect.FieldDescripto
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsRequest"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsRequest"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,9 +136,9 @@ func (x *fastReflection_QueryParamsRequest) Get(descriptor protoreflect.FieldDes
|
|||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsRequest"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsRequest"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsRequest does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsRequest does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,9 +156,9 @@ func (x *fastReflection_QueryParamsRequest) Set(fd protoreflect.FieldDescriptor,
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsRequest"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsRequest"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,9 +176,9 @@ func (x *fastReflection_QueryParamsRequest) Mutable(fd protoreflect.FieldDescrip
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsRequest"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsRequest"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,9 +189,9 @@ func (x *fastReflection_QueryParamsRequest) NewField(fd protoreflect.FieldDescri
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsRequest"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsRequest"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsRequest does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ func (x *fastReflection_QueryParamsRequest) NewField(fd protoreflect.FieldDescri
|
|||||||
func (x *fastReflection_QueryParamsRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_QueryParamsRequest) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in service.v1.QueryParamsRequest", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.v1.QueryParamsRequest", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -375,8 +375,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_v1_query_proto_init()
|
file_svc_v1_query_proto_init()
|
||||||
md_QueryParamsResponse = File_service_v1_query_proto.Messages().ByName("QueryParamsResponse")
|
md_QueryParamsResponse = File_svc_v1_query_proto.Messages().ByName("QueryParamsResponse")
|
||||||
fd_QueryParamsResponse_params = md_QueryParamsResponse.Fields().ByName("params")
|
fd_QueryParamsResponse_params = md_QueryParamsResponse.Fields().ByName("params")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -389,7 +389,7 @@ func (x *QueryParamsResponse) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *QueryParamsResponse) slowProtoReflect() protoreflect.Message {
|
func (x *QueryParamsResponse) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_v1_query_proto_msgTypes[1]
|
mi := &file_svc_v1_query_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -466,13 +466,13 @@ func (x *fastReflection_QueryParamsResponse) Range(f func(protoreflect.FieldDesc
|
|||||||
// a repeated field is populated if it is non-empty.
|
// a repeated field is populated if it is non-empty.
|
||||||
func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool {
|
func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor) bool {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.QueryParamsResponse.params":
|
case "svc.v1.QueryParamsResponse.params":
|
||||||
return x.Params != nil
|
return x.Params != nil
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,13 +484,13 @@ func (x *fastReflection_QueryParamsResponse) Has(fd protoreflect.FieldDescriptor
|
|||||||
// Clear is a mutating operation and unsafe for concurrent use.
|
// Clear is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescriptor) {
|
func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescriptor) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.QueryParamsResponse.params":
|
case "svc.v1.QueryParamsResponse.params":
|
||||||
x.Params = nil
|
x.Params = nil
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,14 +502,14 @@ func (x *fastReflection_QueryParamsResponse) Clear(fd protoreflect.FieldDescript
|
|||||||
// of the value; to obtain a mutable reference, use Mutable.
|
// of the value; to obtain a mutable reference, use Mutable.
|
||||||
func (x *fastReflection_QueryParamsResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_QueryParamsResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
case "service.v1.QueryParamsResponse.params":
|
case "svc.v1.QueryParamsResponse.params":
|
||||||
value := x.Params
|
value := x.Params
|
||||||
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsResponse does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsResponse does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -525,13 +525,13 @@ func (x *fastReflection_QueryParamsResponse) Get(descriptor protoreflect.FieldDe
|
|||||||
// Set is a mutating operation and unsafe for concurrent use.
|
// Set is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_QueryParamsResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
func (x *fastReflection_QueryParamsResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.QueryParamsResponse.params":
|
case "svc.v1.QueryParamsResponse.params":
|
||||||
x.Params = value.Message().Interface().(*Params)
|
x.Params = value.Message().Interface().(*Params)
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,16 +547,16 @@ func (x *fastReflection_QueryParamsResponse) Set(fd protoreflect.FieldDescriptor
|
|||||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_QueryParamsResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_QueryParamsResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.QueryParamsResponse.params":
|
case "svc.v1.QueryParamsResponse.params":
|
||||||
if x.Params == nil {
|
if x.Params == nil {
|
||||||
x.Params = new(Params)
|
x.Params = new(Params)
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfMessage(x.Params.ProtoReflect())
|
return protoreflect.ValueOfMessage(x.Params.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,14 +565,14 @@ func (x *fastReflection_QueryParamsResponse) Mutable(fd protoreflect.FieldDescri
|
|||||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||||
func (x *fastReflection_QueryParamsResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_QueryParamsResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.QueryParamsResponse.params":
|
case "svc.v1.QueryParamsResponse.params":
|
||||||
m := new(Params)
|
m := new(Params)
|
||||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.QueryParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.QueryParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.QueryParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -582,7 +582,7 @@ func (x *fastReflection_QueryParamsResponse) NewField(fd protoreflect.FieldDescr
|
|||||||
func (x *fastReflection_QueryParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_QueryParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in service.v1.QueryParamsResponse", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.v1.QueryParamsResponse", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -808,7 +808,7 @@ func (x *fastReflection_QueryParamsResponse) ProtoMethods() *protoiface.Methods
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.27.0
|
// protoc-gen-go v1.27.0
|
||||||
// protoc (unknown)
|
// protoc (unknown)
|
||||||
// source: service/v1/query.proto
|
// source: svc/v1/query.proto
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
@@ -827,7 +827,7 @@ type QueryParamsRequest struct {
|
|||||||
func (x *QueryParamsRequest) Reset() {
|
func (x *QueryParamsRequest) Reset() {
|
||||||
*x = QueryParamsRequest{}
|
*x = QueryParamsRequest{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_v1_query_proto_msgTypes[0]
|
mi := &file_svc_v1_query_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -841,7 +841,7 @@ func (*QueryParamsRequest) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use QueryParamsRequest.ProtoReflect.Descriptor instead.
|
// Deprecated: Use QueryParamsRequest.ProtoReflect.Descriptor instead.
|
||||||
func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
|
func (*QueryParamsRequest) Descriptor() ([]byte, []int) {
|
||||||
return file_service_v1_query_proto_rawDescGZIP(), []int{0}
|
return file_svc_v1_query_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryParamsResponse is the response type for the Query/Params RPC method.
|
// QueryParamsResponse is the response type for the Query/Params RPC method.
|
||||||
@@ -857,7 +857,7 @@ type QueryParamsResponse struct {
|
|||||||
func (x *QueryParamsResponse) Reset() {
|
func (x *QueryParamsResponse) Reset() {
|
||||||
*x = QueryParamsResponse{}
|
*x = QueryParamsResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_v1_query_proto_msgTypes[1]
|
mi := &file_svc_v1_query_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -871,7 +871,7 @@ func (*QueryParamsResponse) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use QueryParamsResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use QueryParamsResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
|
func (*QueryParamsResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_service_v1_query_proto_rawDescGZIP(), []int{1}
|
return file_svc_v1_query_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *QueryParamsResponse) GetParams() *Params {
|
func (x *QueryParamsResponse) GetParams() *Params {
|
||||||
@@ -881,62 +881,58 @@ func (x *QueryParamsResponse) GetParams() *Params {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_service_v1_query_proto protoreflect.FileDescriptor
|
var File_svc_v1_query_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_service_v1_query_proto_rawDesc = []byte{
|
var file_svc_v1_query_proto_rawDesc = []byte{
|
||||||
0x0a, 0x16, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65,
|
0x0a, 0x12, 0x73, 0x76, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x71, 0x75, 0x65, 0x72, 0x79, 0x2e, 0x70,
|
||||||
0x72, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63,
|
0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f,
|
||||||
0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69,
|
0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74,
|
||||||
0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f,
|
0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x73, 0x76, 0x63, 0x2f,
|
||||||
0x74, 0x6f, 0x1a, 0x18, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x67,
|
0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||||
0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x14, 0x0a, 0x12,
|
0x22, 0x14, 0x0a, 0x12, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52,
|
||||||
0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65,
|
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x3d, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50,
|
||||||
0x73, 0x74, 0x22, 0x41, 0x0a, 0x13, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d,
|
0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x26, 0x0a,
|
||||||
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x06, 0x70, 0x61, 0x72,
|
0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e,
|
||||||
0x61, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76,
|
0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, 0x70,
|
||||||
0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x06, 0x70,
|
0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x62, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x59,
|
||||||
0x61, 0x72, 0x61, 0x6d, 0x73, 0x32, 0x6e, 0x0a, 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x65,
|
0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1a, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76,
|
||||||
0x0a, 0x06, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69,
|
0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x71,
|
||||||
0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d,
|
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75,
|
||||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69,
|
0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
|
||||||
0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x61, 0x72, 0x61, 0x6d,
|
0x65, 0x22, 0x16, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x10, 0x12, 0x0e, 0x2f, 0x73, 0x76, 0x63, 0x2f,
|
||||||
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x1a, 0x82, 0xd3, 0xe4, 0x93, 0x02,
|
0x76, 0x31, 0x2f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x7a, 0x0a, 0x0a, 0x63, 0x6f, 0x6d,
|
||||||
0x14, 0x12, 0x12, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x70,
|
0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50, 0x72,
|
||||||
0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x96, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65,
|
0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0a, 0x51, 0x75, 0x65, 0x72, 0x79, 0x50,
|
0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70,
|
||||||
0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
|
0x69, 0x2f, 0x73, 0x76, 0x63, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x76, 0x63, 0x76, 0x31, 0xa2, 0x02,
|
||||||
0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61,
|
0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x53, 0x76, 0x63, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x06,
|
||||||
0x70, 0x69, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x65,
|
0x53, 0x76, 0x63, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x53, 0x76, 0x63, 0x5c, 0x56, 0x31, 0x5c,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x0a,
|
0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x53, 0x76,
|
||||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0a, 0x53, 0x65, 0x72,
|
0x63, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
0x76, 0x69, 0x63, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x16, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
|
||||||
0x65, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
|
||||||
0xea, 0x02, 0x0b, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06,
|
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_service_v1_query_proto_rawDescOnce sync.Once
|
file_svc_v1_query_proto_rawDescOnce sync.Once
|
||||||
file_service_v1_query_proto_rawDescData = file_service_v1_query_proto_rawDesc
|
file_svc_v1_query_proto_rawDescData = file_svc_v1_query_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_service_v1_query_proto_rawDescGZIP() []byte {
|
func file_svc_v1_query_proto_rawDescGZIP() []byte {
|
||||||
file_service_v1_query_proto_rawDescOnce.Do(func() {
|
file_svc_v1_query_proto_rawDescOnce.Do(func() {
|
||||||
file_service_v1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_v1_query_proto_rawDescData)
|
file_svc_v1_query_proto_rawDescData = protoimpl.X.CompressGZIP(file_svc_v1_query_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_service_v1_query_proto_rawDescData
|
return file_svc_v1_query_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_service_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
var file_svc_v1_query_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||||
var file_service_v1_query_proto_goTypes = []interface{}{
|
var file_svc_v1_query_proto_goTypes = []interface{}{
|
||||||
(*QueryParamsRequest)(nil), // 0: service.v1.QueryParamsRequest
|
(*QueryParamsRequest)(nil), // 0: svc.v1.QueryParamsRequest
|
||||||
(*QueryParamsResponse)(nil), // 1: service.v1.QueryParamsResponse
|
(*QueryParamsResponse)(nil), // 1: svc.v1.QueryParamsResponse
|
||||||
(*Params)(nil), // 2: service.v1.Params
|
(*Params)(nil), // 2: svc.v1.Params
|
||||||
}
|
}
|
||||||
var file_service_v1_query_proto_depIdxs = []int32{
|
var file_svc_v1_query_proto_depIdxs = []int32{
|
||||||
2, // 0: service.v1.QueryParamsResponse.params:type_name -> service.v1.Params
|
2, // 0: svc.v1.QueryParamsResponse.params:type_name -> svc.v1.Params
|
||||||
0, // 1: service.v1.Query.Params:input_type -> service.v1.QueryParamsRequest
|
0, // 1: svc.v1.Query.Params:input_type -> svc.v1.QueryParamsRequest
|
||||||
1, // 2: service.v1.Query.Params:output_type -> service.v1.QueryParamsResponse
|
1, // 2: svc.v1.Query.Params:output_type -> svc.v1.QueryParamsResponse
|
||||||
2, // [2:3] is the sub-list for method output_type
|
2, // [2:3] is the sub-list for method output_type
|
||||||
1, // [1:2] is the sub-list for method input_type
|
1, // [1:2] is the sub-list for method input_type
|
||||||
1, // [1:1] is the sub-list for extension type_name
|
1, // [1:1] is the sub-list for extension type_name
|
||||||
@@ -944,14 +940,14 @@ var file_service_v1_query_proto_depIdxs = []int32{
|
|||||||
0, // [0:1] is the sub-list for field type_name
|
0, // [0:1] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_service_v1_query_proto_init() }
|
func init() { file_svc_v1_query_proto_init() }
|
||||||
func file_service_v1_query_proto_init() {
|
func file_svc_v1_query_proto_init() {
|
||||||
if File_service_v1_query_proto != nil {
|
if File_svc_v1_query_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
file_service_v1_genesis_proto_init()
|
file_svc_v1_genesis_proto_init()
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_service_v1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_v1_query_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*QueryParamsRequest); i {
|
switch v := v.(*QueryParamsRequest); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -963,7 +959,7 @@ func file_service_v1_query_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_service_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_v1_query_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*QueryParamsResponse); i {
|
switch v := v.(*QueryParamsResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -980,18 +976,18 @@ func file_service_v1_query_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_service_v1_query_proto_rawDesc,
|
RawDescriptor: file_svc_v1_query_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 2,
|
NumMessages: 2,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
GoTypes: file_service_v1_query_proto_goTypes,
|
GoTypes: file_svc_v1_query_proto_goTypes,
|
||||||
DependencyIndexes: file_service_v1_query_proto_depIdxs,
|
DependencyIndexes: file_svc_v1_query_proto_depIdxs,
|
||||||
MessageInfos: file_service_v1_query_proto_msgTypes,
|
MessageInfos: file_svc_v1_query_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_service_v1_query_proto = out.File
|
File_svc_v1_query_proto = out.File
|
||||||
file_service_v1_query_proto_rawDesc = nil
|
file_svc_v1_query_proto_rawDesc = nil
|
||||||
file_service_v1_query_proto_goTypes = nil
|
file_svc_v1_query_proto_goTypes = nil
|
||||||
file_service_v1_query_proto_depIdxs = nil
|
file_svc_v1_query_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
// - protoc (unknown)
|
// - protoc (unknown)
|
||||||
// source: service/v1/query.proto
|
// source: svc/v1/query.proto
|
||||||
|
|
||||||
package servicev1
|
package svcv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
@@ -19,7 +19,7 @@ import (
|
|||||||
const _ = grpc.SupportPackageIsVersion9
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Query_Params_FullMethodName = "/service.v1.Query/Params"
|
Query_Params_FullMethodName = "/svc.v1.Query/Params"
|
||||||
)
|
)
|
||||||
|
|
||||||
// QueryClient is the client API for Query service.
|
// QueryClient is the client API for Query service.
|
||||||
@@ -114,7 +114,7 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf
|
|||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
var Query_ServiceDesc = grpc.ServiceDesc{
|
var Query_ServiceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "service.v1.Query",
|
ServiceName: "svc.v1.Query",
|
||||||
HandlerType: (*QueryServer)(nil),
|
HandlerType: (*QueryServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
@@ -123,5 +123,5 @@ var Query_ServiceDesc = grpc.ServiceDesc{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "service/v1/query.proto",
|
Metadata: "svc/v1/query.proto",
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
||||||
|
|
||||||
package servicev1
|
package svcv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
@@ -9,19 +9,177 @@ import (
|
|||||||
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DomainTable interface {
|
||||||
|
Insert(ctx context.Context, domain *Domain) error
|
||||||
|
InsertReturningId(ctx context.Context, domain *Domain) (uint64, error)
|
||||||
|
LastInsertedSequence(ctx context.Context) (uint64, error)
|
||||||
|
Update(ctx context.Context, domain *Domain) error
|
||||||
|
Save(ctx context.Context, domain *Domain) error
|
||||||
|
Delete(ctx context.Context, domain *Domain) error
|
||||||
|
Has(ctx context.Context, id uint64) (found bool, err error)
|
||||||
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
|
Get(ctx context.Context, id uint64) (*Domain, error)
|
||||||
|
HasByOrigin(ctx context.Context, origin string) (found bool, err error)
|
||||||
|
// GetByOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
|
GetByOrigin(ctx context.Context, origin string) (*Domain, error)
|
||||||
|
List(ctx context.Context, prefixKey DomainIndexKey, opts ...ormlist.Option) (DomainIterator, error)
|
||||||
|
ListRange(ctx context.Context, from, to DomainIndexKey, opts ...ormlist.Option) (DomainIterator, error)
|
||||||
|
DeleteBy(ctx context.Context, prefixKey DomainIndexKey) error
|
||||||
|
DeleteRange(ctx context.Context, from, to DomainIndexKey) error
|
||||||
|
|
||||||
|
doNotImplement()
|
||||||
|
}
|
||||||
|
|
||||||
|
type DomainIterator struct {
|
||||||
|
ormtable.Iterator
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i DomainIterator) Value() (*Domain, error) {
|
||||||
|
var domain Domain
|
||||||
|
err := i.UnmarshalMessage(&domain)
|
||||||
|
return &domain, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type DomainIndexKey interface {
|
||||||
|
id() uint32
|
||||||
|
values() []interface{}
|
||||||
|
domainIndexKey()
|
||||||
|
}
|
||||||
|
|
||||||
|
// primary key starting index..
|
||||||
|
type DomainPrimaryKey = DomainIdIndexKey
|
||||||
|
|
||||||
|
type DomainIdIndexKey struct {
|
||||||
|
vs []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x DomainIdIndexKey) id() uint32 { return 0 }
|
||||||
|
func (x DomainIdIndexKey) values() []interface{} { return x.vs }
|
||||||
|
func (x DomainIdIndexKey) domainIndexKey() {}
|
||||||
|
|
||||||
|
func (this DomainIdIndexKey) WithId(id uint64) DomainIdIndexKey {
|
||||||
|
this.vs = []interface{}{id}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
type DomainOriginIndexKey struct {
|
||||||
|
vs []interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x DomainOriginIndexKey) id() uint32 { return 1 }
|
||||||
|
func (x DomainOriginIndexKey) values() []interface{} { return x.vs }
|
||||||
|
func (x DomainOriginIndexKey) domainIndexKey() {}
|
||||||
|
|
||||||
|
func (this DomainOriginIndexKey) WithOrigin(origin string) DomainOriginIndexKey {
|
||||||
|
this.vs = []interface{}{origin}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
type domainTable struct {
|
||||||
|
table ormtable.AutoIncrementTable
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) Insert(ctx context.Context, domain *Domain) error {
|
||||||
|
return this.table.Insert(ctx, domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) Update(ctx context.Context, domain *Domain) error {
|
||||||
|
return this.table.Update(ctx, domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) Save(ctx context.Context, domain *Domain) error {
|
||||||
|
return this.table.Save(ctx, domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) Delete(ctx context.Context, domain *Domain) error {
|
||||||
|
return this.table.Delete(ctx, domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) InsertReturningId(ctx context.Context, domain *Domain) (uint64, error) {
|
||||||
|
return this.table.InsertReturningPKey(ctx, domain)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
||||||
|
return this.table.LastInsertedSequence(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) Has(ctx context.Context, id uint64) (found bool, err error) {
|
||||||
|
return this.table.PrimaryKey().Has(ctx, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) Get(ctx context.Context, id uint64) (*Domain, error) {
|
||||||
|
var domain Domain
|
||||||
|
found, err := this.table.PrimaryKey().Get(ctx, &domain, id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, ormerrors.NotFound
|
||||||
|
}
|
||||||
|
return &domain, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) HasByOrigin(ctx context.Context, origin string) (found bool, err error) {
|
||||||
|
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
||||||
|
origin,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) GetByOrigin(ctx context.Context, origin string) (*Domain, error) {
|
||||||
|
var domain Domain
|
||||||
|
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &domain,
|
||||||
|
origin,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
return nil, ormerrors.NotFound
|
||||||
|
}
|
||||||
|
return &domain, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) List(ctx context.Context, prefixKey DomainIndexKey, opts ...ormlist.Option) (DomainIterator, error) {
|
||||||
|
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
||||||
|
return DomainIterator{it}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) ListRange(ctx context.Context, from, to DomainIndexKey, opts ...ormlist.Option) (DomainIterator, error) {
|
||||||
|
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
||||||
|
return DomainIterator{it}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) DeleteBy(ctx context.Context, prefixKey DomainIndexKey) error {
|
||||||
|
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) DeleteRange(ctx context.Context, from, to DomainIndexKey) error {
|
||||||
|
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this domainTable) doNotImplement() {}
|
||||||
|
|
||||||
|
var _ DomainTable = domainTable{}
|
||||||
|
|
||||||
|
func NewDomainTable(db ormtable.Schema) (DomainTable, error) {
|
||||||
|
table := db.GetTable(&Domain{})
|
||||||
|
if table == nil {
|
||||||
|
return nil, ormerrors.TableNotFound.Wrap(string((&Domain{}).ProtoReflect().Descriptor().FullName()))
|
||||||
|
}
|
||||||
|
return domainTable{table.(ormtable.AutoIncrementTable)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
type MetadataTable interface {
|
type MetadataTable interface {
|
||||||
Insert(ctx context.Context, metadata *Metadata) error
|
Insert(ctx context.Context, metadata *Metadata) error
|
||||||
InsertReturningId(ctx context.Context, metadata *Metadata) (uint64, error)
|
|
||||||
LastInsertedSequence(ctx context.Context) (uint64, error)
|
|
||||||
Update(ctx context.Context, metadata *Metadata) error
|
Update(ctx context.Context, metadata *Metadata) error
|
||||||
Save(ctx context.Context, metadata *Metadata) error
|
Save(ctx context.Context, metadata *Metadata) error
|
||||||
Delete(ctx context.Context, metadata *Metadata) error
|
Delete(ctx context.Context, metadata *Metadata) error
|
||||||
Has(ctx context.Context, id uint64) (found bool, err error)
|
Has(ctx context.Context, id string) (found bool, err error)
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
Get(ctx context.Context, id uint64) (*Metadata, error)
|
Get(ctx context.Context, id string) (*Metadata, error)
|
||||||
HasByOrigin(ctx context.Context, origin string) (found bool, err error)
|
HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error)
|
||||||
// GetByOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
// GetBySubjectOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
||||||
GetByOrigin(ctx context.Context, origin string) (*Metadata, error)
|
GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Metadata, error)
|
||||||
List(ctx context.Context, prefixKey MetadataIndexKey, opts ...ormlist.Option) (MetadataIterator, error)
|
List(ctx context.Context, prefixKey MetadataIndexKey, opts ...ormlist.Option) (MetadataIterator, error)
|
||||||
ListRange(ctx context.Context, from, to MetadataIndexKey, opts ...ormlist.Option) (MetadataIterator, error)
|
ListRange(ctx context.Context, from, to MetadataIndexKey, opts ...ormlist.Option) (MetadataIterator, error)
|
||||||
DeleteBy(ctx context.Context, prefixKey MetadataIndexKey) error
|
DeleteBy(ctx context.Context, prefixKey MetadataIndexKey) error
|
||||||
@@ -57,26 +215,31 @@ func (x MetadataIdIndexKey) id() uint32 { return 0 }
|
|||||||
func (x MetadataIdIndexKey) values() []interface{} { return x.vs }
|
func (x MetadataIdIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x MetadataIdIndexKey) metadataIndexKey() {}
|
func (x MetadataIdIndexKey) metadataIndexKey() {}
|
||||||
|
|
||||||
func (this MetadataIdIndexKey) WithId(id uint64) MetadataIdIndexKey {
|
func (this MetadataIdIndexKey) WithId(id string) MetadataIdIndexKey {
|
||||||
this.vs = []interface{}{id}
|
this.vs = []interface{}{id}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetadataOriginIndexKey struct {
|
type MetadataSubjectOriginIndexKey struct {
|
||||||
vs []interface{}
|
vs []interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x MetadataOriginIndexKey) id() uint32 { return 1 }
|
func (x MetadataSubjectOriginIndexKey) id() uint32 { return 1 }
|
||||||
func (x MetadataOriginIndexKey) values() []interface{} { return x.vs }
|
func (x MetadataSubjectOriginIndexKey) values() []interface{} { return x.vs }
|
||||||
func (x MetadataOriginIndexKey) metadataIndexKey() {}
|
func (x MetadataSubjectOriginIndexKey) metadataIndexKey() {}
|
||||||
|
|
||||||
func (this MetadataOriginIndexKey) WithOrigin(origin string) MetadataOriginIndexKey {
|
func (this MetadataSubjectOriginIndexKey) WithSubject(subject string) MetadataSubjectOriginIndexKey {
|
||||||
this.vs = []interface{}{origin}
|
this.vs = []interface{}{subject}
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this MetadataSubjectOriginIndexKey) WithSubjectOrigin(subject string, origin string) MetadataSubjectOriginIndexKey {
|
||||||
|
this.vs = []interface{}{subject, origin}
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
type metadataTable struct {
|
type metadataTable struct {
|
||||||
table ormtable.AutoIncrementTable
|
table ormtable.Table
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this metadataTable) Insert(ctx context.Context, metadata *Metadata) error {
|
func (this metadataTable) Insert(ctx context.Context, metadata *Metadata) error {
|
||||||
@@ -95,19 +258,11 @@ func (this metadataTable) Delete(ctx context.Context, metadata *Metadata) error
|
|||||||
return this.table.Delete(ctx, metadata)
|
return this.table.Delete(ctx, metadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this metadataTable) InsertReturningId(ctx context.Context, metadata *Metadata) (uint64, error) {
|
func (this metadataTable) Has(ctx context.Context, id string) (found bool, err error) {
|
||||||
return this.table.InsertReturningPKey(ctx, metadata)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this metadataTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
|
||||||
return this.table.LastInsertedSequence(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this metadataTable) Has(ctx context.Context, id uint64) (found bool, err error) {
|
|
||||||
return this.table.PrimaryKey().Has(ctx, id)
|
return this.table.PrimaryKey().Has(ctx, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this metadataTable) Get(ctx context.Context, id uint64) (*Metadata, error) {
|
func (this metadataTable) Get(ctx context.Context, id string) (*Metadata, error) {
|
||||||
var metadata Metadata
|
var metadata Metadata
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &metadata, id)
|
found, err := this.table.PrimaryKey().Get(ctx, &metadata, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -119,15 +274,17 @@ func (this metadataTable) Get(ctx context.Context, id uint64) (*Metadata, error)
|
|||||||
return &metadata, nil
|
return &metadata, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this metadataTable) HasByOrigin(ctx context.Context, origin string) (found bool, err error) {
|
func (this metadataTable) HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error) {
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
||||||
|
subject,
|
||||||
origin,
|
origin,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this metadataTable) GetByOrigin(ctx context.Context, origin string) (*Metadata, error) {
|
func (this metadataTable) GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Metadata, error) {
|
||||||
var metadata Metadata
|
var metadata Metadata
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &metadata,
|
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &metadata,
|
||||||
|
subject,
|
||||||
origin,
|
origin,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -166,203 +323,46 @@ func NewMetadataTable(db ormtable.Schema) (MetadataTable, error) {
|
|||||||
if table == nil {
|
if table == nil {
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Metadata{}).ProtoReflect().Descriptor().FullName()))
|
return nil, ormerrors.TableNotFound.Wrap(string((&Metadata{}).ProtoReflect().Descriptor().FullName()))
|
||||||
}
|
}
|
||||||
return metadataTable{table.(ormtable.AutoIncrementTable)}, nil
|
return metadataTable{table}, nil
|
||||||
}
|
|
||||||
|
|
||||||
type ProfileTable interface {
|
|
||||||
Insert(ctx context.Context, profile *Profile) error
|
|
||||||
Update(ctx context.Context, profile *Profile) error
|
|
||||||
Save(ctx context.Context, profile *Profile) error
|
|
||||||
Delete(ctx context.Context, profile *Profile) error
|
|
||||||
Has(ctx context.Context, id string) (found bool, err error)
|
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
Get(ctx context.Context, id string) (*Profile, error)
|
|
||||||
HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error)
|
|
||||||
// GetBySubjectOrigin returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Profile, error)
|
|
||||||
List(ctx context.Context, prefixKey ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error)
|
|
||||||
ListRange(ctx context.Context, from, to ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error)
|
|
||||||
DeleteBy(ctx context.Context, prefixKey ProfileIndexKey) error
|
|
||||||
DeleteRange(ctx context.Context, from, to ProfileIndexKey) error
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProfileIterator struct {
|
|
||||||
ormtable.Iterator
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i ProfileIterator) Value() (*Profile, error) {
|
|
||||||
var profile Profile
|
|
||||||
err := i.UnmarshalMessage(&profile)
|
|
||||||
return &profile, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProfileIndexKey interface {
|
|
||||||
id() uint32
|
|
||||||
values() []interface{}
|
|
||||||
profileIndexKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
// primary key starting index..
|
|
||||||
type ProfilePrimaryKey = ProfileIdIndexKey
|
|
||||||
|
|
||||||
type ProfileIdIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x ProfileIdIndexKey) id() uint32 { return 0 }
|
|
||||||
func (x ProfileIdIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x ProfileIdIndexKey) profileIndexKey() {}
|
|
||||||
|
|
||||||
func (this ProfileIdIndexKey) WithId(id string) ProfileIdIndexKey {
|
|
||||||
this.vs = []interface{}{id}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type ProfileSubjectOriginIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x ProfileSubjectOriginIndexKey) id() uint32 { return 1 }
|
|
||||||
func (x ProfileSubjectOriginIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x ProfileSubjectOriginIndexKey) profileIndexKey() {}
|
|
||||||
|
|
||||||
func (this ProfileSubjectOriginIndexKey) WithSubject(subject string) ProfileSubjectOriginIndexKey {
|
|
||||||
this.vs = []interface{}{subject}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this ProfileSubjectOriginIndexKey) WithSubjectOrigin(subject string, origin string) ProfileSubjectOriginIndexKey {
|
|
||||||
this.vs = []interface{}{subject, origin}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type profileTable struct {
|
|
||||||
table ormtable.Table
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) Insert(ctx context.Context, profile *Profile) error {
|
|
||||||
return this.table.Insert(ctx, profile)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) Update(ctx context.Context, profile *Profile) error {
|
|
||||||
return this.table.Update(ctx, profile)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) Save(ctx context.Context, profile *Profile) error {
|
|
||||||
return this.table.Save(ctx, profile)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) Delete(ctx context.Context, profile *Profile) error {
|
|
||||||
return this.table.Delete(ctx, profile)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) Has(ctx context.Context, id string) (found bool, err error) {
|
|
||||||
return this.table.PrimaryKey().Has(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) Get(ctx context.Context, id string) (*Profile, error) {
|
|
||||||
var profile Profile
|
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &profile, id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &profile, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) HasBySubjectOrigin(ctx context.Context, subject string, origin string) (found bool, err error) {
|
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
|
||||||
subject,
|
|
||||||
origin,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) GetBySubjectOrigin(ctx context.Context, subject string, origin string) (*Profile, error) {
|
|
||||||
var profile Profile
|
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &profile,
|
|
||||||
subject,
|
|
||||||
origin,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &profile, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) List(ctx context.Context, prefixKey ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
|
||||||
return ProfileIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) ListRange(ctx context.Context, from, to ProfileIndexKey, opts ...ormlist.Option) (ProfileIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
|
||||||
return ProfileIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) DeleteBy(ctx context.Context, prefixKey ProfileIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) DeleteRange(ctx context.Context, from, to ProfileIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this profileTable) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ ProfileTable = profileTable{}
|
|
||||||
|
|
||||||
func NewProfileTable(db ormtable.Schema) (ProfileTable, error) {
|
|
||||||
table := db.GetTable(&Profile{})
|
|
||||||
if table == nil {
|
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&Profile{}).ProtoReflect().Descriptor().FullName()))
|
|
||||||
}
|
|
||||||
return profileTable{table}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type StateStore interface {
|
type StateStore interface {
|
||||||
|
DomainTable() DomainTable
|
||||||
MetadataTable() MetadataTable
|
MetadataTable() MetadataTable
|
||||||
ProfileTable() ProfileTable
|
|
||||||
|
|
||||||
doNotImplement()
|
doNotImplement()
|
||||||
}
|
}
|
||||||
|
|
||||||
type stateStore struct {
|
type stateStore struct {
|
||||||
|
domain DomainTable
|
||||||
metadata MetadataTable
|
metadata MetadataTable
|
||||||
profile ProfileTable
|
}
|
||||||
|
|
||||||
|
func (x stateStore) DomainTable() DomainTable {
|
||||||
|
return x.domain
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x stateStore) MetadataTable() MetadataTable {
|
func (x stateStore) MetadataTable() MetadataTable {
|
||||||
return x.metadata
|
return x.metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x stateStore) ProfileTable() ProfileTable {
|
|
||||||
return x.profile
|
|
||||||
}
|
|
||||||
|
|
||||||
func (stateStore) doNotImplement() {}
|
func (stateStore) doNotImplement() {}
|
||||||
|
|
||||||
var _ StateStore = stateStore{}
|
var _ StateStore = stateStore{}
|
||||||
|
|
||||||
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
||||||
|
domainTable, err := NewDomainTable(db)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
metadataTable, err := NewMetadataTable(db)
|
metadataTable, err := NewMetadataTable(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
profileTable, err := NewProfileTable(db)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return stateStore{
|
return stateStore{
|
||||||
|
domainTable,
|
||||||
metadataTable,
|
metadataTable,
|
||||||
profileTable,
|
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
||||||
package servicev1
|
package svcv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "cosmossdk.io/api/cosmos/msg/v1"
|
_ "cosmossdk.io/api/cosmos/msg/v1"
|
||||||
@@ -22,8 +22,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_v1_tx_proto_init()
|
file_svc_v1_tx_proto_init()
|
||||||
md_MsgUpdateParams = File_service_v1_tx_proto.Messages().ByName("MsgUpdateParams")
|
md_MsgUpdateParams = File_svc_v1_tx_proto.Messages().ByName("MsgUpdateParams")
|
||||||
fd_MsgUpdateParams_authority = md_MsgUpdateParams.Fields().ByName("authority")
|
fd_MsgUpdateParams_authority = md_MsgUpdateParams.Fields().ByName("authority")
|
||||||
fd_MsgUpdateParams_params = md_MsgUpdateParams.Fields().ByName("params")
|
fd_MsgUpdateParams_params = md_MsgUpdateParams.Fields().ByName("params")
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ func (x *MsgUpdateParams) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgUpdateParams) slowProtoReflect() protoreflect.Message {
|
func (x *MsgUpdateParams) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[0]
|
mi := &file_svc_v1_tx_proto_msgTypes[0]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -120,15 +120,15 @@ func (x *fastReflection_MsgUpdateParams) Range(f func(protoreflect.FieldDescript
|
|||||||
// a repeated field is populated if it is non-empty.
|
// a repeated field is populated if it is non-empty.
|
||||||
func (x *fastReflection_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bool {
|
func (x *fastReflection_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bool {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgUpdateParams.authority":
|
case "svc.v1.MsgUpdateParams.authority":
|
||||||
return x.Authority != ""
|
return x.Authority != ""
|
||||||
case "service.v1.MsgUpdateParams.params":
|
case "svc.v1.MsgUpdateParams.params":
|
||||||
return x.Params != nil
|
return x.Params != nil
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParams"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParams"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,15 +140,15 @@ func (x *fastReflection_MsgUpdateParams) Has(fd protoreflect.FieldDescriptor) bo
|
|||||||
// Clear is a mutating operation and unsafe for concurrent use.
|
// Clear is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgUpdateParams) Clear(fd protoreflect.FieldDescriptor) {
|
func (x *fastReflection_MsgUpdateParams) Clear(fd protoreflect.FieldDescriptor) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgUpdateParams.authority":
|
case "svc.v1.MsgUpdateParams.authority":
|
||||||
x.Authority = ""
|
x.Authority = ""
|
||||||
case "service.v1.MsgUpdateParams.params":
|
case "svc.v1.MsgUpdateParams.params":
|
||||||
x.Params = nil
|
x.Params = nil
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParams"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParams"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,17 +160,17 @@ func (x *fastReflection_MsgUpdateParams) Clear(fd protoreflect.FieldDescriptor)
|
|||||||
// of the value; to obtain a mutable reference, use Mutable.
|
// of the value; to obtain a mutable reference, use Mutable.
|
||||||
func (x *fastReflection_MsgUpdateParams) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgUpdateParams) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
case "service.v1.MsgUpdateParams.authority":
|
case "svc.v1.MsgUpdateParams.authority":
|
||||||
value := x.Authority
|
value := x.Authority
|
||||||
return protoreflect.ValueOfString(value)
|
return protoreflect.ValueOfString(value)
|
||||||
case "service.v1.MsgUpdateParams.params":
|
case "svc.v1.MsgUpdateParams.params":
|
||||||
value := x.Params
|
value := x.Params
|
||||||
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParams"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParams"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParams does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParams does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,15 +186,15 @@ func (x *fastReflection_MsgUpdateParams) Get(descriptor protoreflect.FieldDescri
|
|||||||
// Set is a mutating operation and unsafe for concurrent use.
|
// Set is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgUpdateParams) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
func (x *fastReflection_MsgUpdateParams) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgUpdateParams.authority":
|
case "svc.v1.MsgUpdateParams.authority":
|
||||||
x.Authority = value.Interface().(string)
|
x.Authority = value.Interface().(string)
|
||||||
case "service.v1.MsgUpdateParams.params":
|
case "svc.v1.MsgUpdateParams.params":
|
||||||
x.Params = value.Message().Interface().(*Params)
|
x.Params = value.Message().Interface().(*Params)
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParams"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParams"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,18 +210,18 @@ func (x *fastReflection_MsgUpdateParams) Set(fd protoreflect.FieldDescriptor, va
|
|||||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgUpdateParams) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgUpdateParams) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgUpdateParams.params":
|
case "svc.v1.MsgUpdateParams.params":
|
||||||
if x.Params == nil {
|
if x.Params == nil {
|
||||||
x.Params = new(Params)
|
x.Params = new(Params)
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfMessage(x.Params.ProtoReflect())
|
return protoreflect.ValueOfMessage(x.Params.ProtoReflect())
|
||||||
case "service.v1.MsgUpdateParams.authority":
|
case "svc.v1.MsgUpdateParams.authority":
|
||||||
panic(fmt.Errorf("field authority of message service.v1.MsgUpdateParams is not mutable"))
|
panic(fmt.Errorf("field authority of message svc.v1.MsgUpdateParams is not mutable"))
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParams"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParams"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -230,16 +230,16 @@ func (x *fastReflection_MsgUpdateParams) Mutable(fd protoreflect.FieldDescriptor
|
|||||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||||
func (x *fastReflection_MsgUpdateParams) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgUpdateParams) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgUpdateParams.authority":
|
case "svc.v1.MsgUpdateParams.authority":
|
||||||
return protoreflect.ValueOfString("")
|
return protoreflect.ValueOfString("")
|
||||||
case "service.v1.MsgUpdateParams.params":
|
case "svc.v1.MsgUpdateParams.params":
|
||||||
m := new(Params)
|
m := new(Params)
|
||||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParams"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParams"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParams does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,7 +249,7 @@ func (x *fastReflection_MsgUpdateParams) NewField(fd protoreflect.FieldDescripto
|
|||||||
func (x *fastReflection_MsgUpdateParams) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_MsgUpdateParams) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in service.v1.MsgUpdateParams", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.v1.MsgUpdateParams", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -519,8 +519,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_v1_tx_proto_init()
|
file_svc_v1_tx_proto_init()
|
||||||
md_MsgUpdateParamsResponse = File_service_v1_tx_proto.Messages().ByName("MsgUpdateParamsResponse")
|
md_MsgUpdateParamsResponse = File_svc_v1_tx_proto.Messages().ByName("MsgUpdateParamsResponse")
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ protoreflect.Message = (*fastReflection_MsgUpdateParamsResponse)(nil)
|
var _ protoreflect.Message = (*fastReflection_MsgUpdateParamsResponse)(nil)
|
||||||
@@ -532,7 +532,7 @@ func (x *MsgUpdateParamsResponse) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgUpdateParamsResponse) slowProtoReflect() protoreflect.Message {
|
func (x *MsgUpdateParamsResponse) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[1]
|
mi := &file_svc_v1_tx_proto_msgTypes[1]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -605,9 +605,9 @@ func (x *fastReflection_MsgUpdateParamsResponse) Has(fd protoreflect.FieldDescri
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,9 +621,9 @@ func (x *fastReflection_MsgUpdateParamsResponse) Clear(fd protoreflect.FieldDesc
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,9 +637,9 @@ func (x *fastReflection_MsgUpdateParamsResponse) Get(descriptor protoreflect.Fie
|
|||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParamsResponse does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParamsResponse does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,9 +657,9 @@ func (x *fastReflection_MsgUpdateParamsResponse) Set(fd protoreflect.FieldDescri
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -677,9 +677,9 @@ func (x *fastReflection_MsgUpdateParamsResponse) Mutable(fd protoreflect.FieldDe
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -690,9 +690,9 @@ func (x *fastReflection_MsgUpdateParamsResponse) NewField(fd protoreflect.FieldD
|
|||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgUpdateParamsResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgUpdateParamsResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgUpdateParamsResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -702,7 +702,7 @@ func (x *fastReflection_MsgUpdateParamsResponse) NewField(fd protoreflect.FieldD
|
|||||||
func (x *fastReflection_MsgUpdateParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_MsgUpdateParamsResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in service.v1.MsgUpdateParamsResponse", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.v1.MsgUpdateParamsResponse", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -877,8 +877,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_v1_tx_proto_init()
|
file_svc_v1_tx_proto_init()
|
||||||
md_MsgRegisterService = File_service_v1_tx_proto.Messages().ByName("MsgRegisterService")
|
md_MsgRegisterService = File_svc_v1_tx_proto.Messages().ByName("MsgRegisterService")
|
||||||
fd_MsgRegisterService_controller = md_MsgRegisterService.Fields().ByName("controller")
|
fd_MsgRegisterService_controller = md_MsgRegisterService.Fields().ByName("controller")
|
||||||
fd_MsgRegisterService_service = md_MsgRegisterService.Fields().ByName("service")
|
fd_MsgRegisterService_service = md_MsgRegisterService.Fields().ByName("service")
|
||||||
}
|
}
|
||||||
@@ -892,7 +892,7 @@ func (x *MsgRegisterService) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgRegisterService) slowProtoReflect() protoreflect.Message {
|
func (x *MsgRegisterService) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[2]
|
mi := &file_svc_v1_tx_proto_msgTypes[2]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -975,15 +975,15 @@ func (x *fastReflection_MsgRegisterService) Range(f func(protoreflect.FieldDescr
|
|||||||
// a repeated field is populated if it is non-empty.
|
// a repeated field is populated if it is non-empty.
|
||||||
func (x *fastReflection_MsgRegisterService) Has(fd protoreflect.FieldDescriptor) bool {
|
func (x *fastReflection_MsgRegisterService) Has(fd protoreflect.FieldDescriptor) bool {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterService.controller":
|
case "svc.v1.MsgRegisterService.controller":
|
||||||
return x.Controller != ""
|
return x.Controller != ""
|
||||||
case "service.v1.MsgRegisterService.service":
|
case "svc.v1.MsgRegisterService.service":
|
||||||
return x.Service != nil
|
return x.Service != nil
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterService"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterService"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -995,15 +995,15 @@ func (x *fastReflection_MsgRegisterService) Has(fd protoreflect.FieldDescriptor)
|
|||||||
// Clear is a mutating operation and unsafe for concurrent use.
|
// Clear is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgRegisterService) Clear(fd protoreflect.FieldDescriptor) {
|
func (x *fastReflection_MsgRegisterService) Clear(fd protoreflect.FieldDescriptor) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterService.controller":
|
case "svc.v1.MsgRegisterService.controller":
|
||||||
x.Controller = ""
|
x.Controller = ""
|
||||||
case "service.v1.MsgRegisterService.service":
|
case "svc.v1.MsgRegisterService.service":
|
||||||
x.Service = nil
|
x.Service = nil
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterService"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterService"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1015,17 +1015,17 @@ func (x *fastReflection_MsgRegisterService) Clear(fd protoreflect.FieldDescripto
|
|||||||
// of the value; to obtain a mutable reference, use Mutable.
|
// of the value; to obtain a mutable reference, use Mutable.
|
||||||
func (x *fastReflection_MsgRegisterService) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgRegisterService) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
case "service.v1.MsgRegisterService.controller":
|
case "svc.v1.MsgRegisterService.controller":
|
||||||
value := x.Controller
|
value := x.Controller
|
||||||
return protoreflect.ValueOfString(value)
|
return protoreflect.ValueOfString(value)
|
||||||
case "service.v1.MsgRegisterService.service":
|
case "svc.v1.MsgRegisterService.service":
|
||||||
value := x.Service
|
value := x.Service
|
||||||
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
return protoreflect.ValueOfMessage(value.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterService"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterService"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterService does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterService does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1041,15 +1041,15 @@ func (x *fastReflection_MsgRegisterService) Get(descriptor protoreflect.FieldDes
|
|||||||
// Set is a mutating operation and unsafe for concurrent use.
|
// Set is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgRegisterService) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
func (x *fastReflection_MsgRegisterService) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterService.controller":
|
case "svc.v1.MsgRegisterService.controller":
|
||||||
x.Controller = value.Interface().(string)
|
x.Controller = value.Interface().(string)
|
||||||
case "service.v1.MsgRegisterService.service":
|
case "svc.v1.MsgRegisterService.service":
|
||||||
x.Service = value.Message().Interface().(*Service)
|
x.Service = value.Message().Interface().(*Service)
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterService"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterService"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1065,18 +1065,18 @@ func (x *fastReflection_MsgRegisterService) Set(fd protoreflect.FieldDescriptor,
|
|||||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgRegisterService) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgRegisterService) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterService.service":
|
case "svc.v1.MsgRegisterService.service":
|
||||||
if x.Service == nil {
|
if x.Service == nil {
|
||||||
x.Service = new(Service)
|
x.Service = new(Service)
|
||||||
}
|
}
|
||||||
return protoreflect.ValueOfMessage(x.Service.ProtoReflect())
|
return protoreflect.ValueOfMessage(x.Service.ProtoReflect())
|
||||||
case "service.v1.MsgRegisterService.controller":
|
case "svc.v1.MsgRegisterService.controller":
|
||||||
panic(fmt.Errorf("field controller of message service.v1.MsgRegisterService is not mutable"))
|
panic(fmt.Errorf("field controller of message svc.v1.MsgRegisterService is not mutable"))
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterService"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterService"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1085,16 +1085,16 @@ func (x *fastReflection_MsgRegisterService) Mutable(fd protoreflect.FieldDescrip
|
|||||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||||
func (x *fastReflection_MsgRegisterService) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgRegisterService) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterService.controller":
|
case "svc.v1.MsgRegisterService.controller":
|
||||||
return protoreflect.ValueOfString("")
|
return protoreflect.ValueOfString("")
|
||||||
case "service.v1.MsgRegisterService.service":
|
case "svc.v1.MsgRegisterService.service":
|
||||||
m := new(Service)
|
m := new(Service)
|
||||||
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
return protoreflect.ValueOfMessage(m.ProtoReflect())
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterService"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterService"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterService does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1104,7 +1104,7 @@ func (x *fastReflection_MsgRegisterService) NewField(fd protoreflect.FieldDescri
|
|||||||
func (x *fastReflection_MsgRegisterService) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_MsgRegisterService) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in service.v1.MsgRegisterService", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.v1.MsgRegisterService", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -1376,8 +1376,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
file_service_v1_tx_proto_init()
|
file_svc_v1_tx_proto_init()
|
||||||
md_MsgRegisterServiceResponse = File_service_v1_tx_proto.Messages().ByName("MsgRegisterServiceResponse")
|
md_MsgRegisterServiceResponse = File_svc_v1_tx_proto.Messages().ByName("MsgRegisterServiceResponse")
|
||||||
fd_MsgRegisterServiceResponse_success = md_MsgRegisterServiceResponse.Fields().ByName("success")
|
fd_MsgRegisterServiceResponse_success = md_MsgRegisterServiceResponse.Fields().ByName("success")
|
||||||
fd_MsgRegisterServiceResponse_did = md_MsgRegisterServiceResponse.Fields().ByName("did")
|
fd_MsgRegisterServiceResponse_did = md_MsgRegisterServiceResponse.Fields().ByName("did")
|
||||||
}
|
}
|
||||||
@@ -1391,7 +1391,7 @@ func (x *MsgRegisterServiceResponse) ProtoReflect() protoreflect.Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgRegisterServiceResponse) slowProtoReflect() protoreflect.Message {
|
func (x *MsgRegisterServiceResponse) slowProtoReflect() protoreflect.Message {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[3]
|
mi := &file_svc_v1_tx_proto_msgTypes[3]
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
if protoimpl.UnsafeEnabled && x != nil {
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
if ms.LoadMessageInfo() == nil {
|
if ms.LoadMessageInfo() == nil {
|
||||||
@@ -1474,15 +1474,15 @@ func (x *fastReflection_MsgRegisterServiceResponse) Range(f func(protoreflect.Fi
|
|||||||
// a repeated field is populated if it is non-empty.
|
// a repeated field is populated if it is non-empty.
|
||||||
func (x *fastReflection_MsgRegisterServiceResponse) Has(fd protoreflect.FieldDescriptor) bool {
|
func (x *fastReflection_MsgRegisterServiceResponse) Has(fd protoreflect.FieldDescriptor) bool {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterServiceResponse.success":
|
case "svc.v1.MsgRegisterServiceResponse.success":
|
||||||
return x.Success != false
|
return x.Success != false
|
||||||
case "service.v1.MsgRegisterServiceResponse.did":
|
case "svc.v1.MsgRegisterServiceResponse.did":
|
||||||
return x.Did != ""
|
return x.Did != ""
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterServiceResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterServiceResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1494,15 +1494,15 @@ func (x *fastReflection_MsgRegisterServiceResponse) Has(fd protoreflect.FieldDes
|
|||||||
// Clear is a mutating operation and unsafe for concurrent use.
|
// Clear is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgRegisterServiceResponse) Clear(fd protoreflect.FieldDescriptor) {
|
func (x *fastReflection_MsgRegisterServiceResponse) Clear(fd protoreflect.FieldDescriptor) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterServiceResponse.success":
|
case "svc.v1.MsgRegisterServiceResponse.success":
|
||||||
x.Success = false
|
x.Success = false
|
||||||
case "service.v1.MsgRegisterServiceResponse.did":
|
case "svc.v1.MsgRegisterServiceResponse.did":
|
||||||
x.Did = ""
|
x.Did = ""
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterServiceResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterServiceResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1514,17 +1514,17 @@ func (x *fastReflection_MsgRegisterServiceResponse) Clear(fd protoreflect.FieldD
|
|||||||
// of the value; to obtain a mutable reference, use Mutable.
|
// of the value; to obtain a mutable reference, use Mutable.
|
||||||
func (x *fastReflection_MsgRegisterServiceResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgRegisterServiceResponse) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch descriptor.FullName() {
|
switch descriptor.FullName() {
|
||||||
case "service.v1.MsgRegisterServiceResponse.success":
|
case "svc.v1.MsgRegisterServiceResponse.success":
|
||||||
value := x.Success
|
value := x.Success
|
||||||
return protoreflect.ValueOfBool(value)
|
return protoreflect.ValueOfBool(value)
|
||||||
case "service.v1.MsgRegisterServiceResponse.did":
|
case "svc.v1.MsgRegisterServiceResponse.did":
|
||||||
value := x.Did
|
value := x.Did
|
||||||
return protoreflect.ValueOfString(value)
|
return protoreflect.ValueOfString(value)
|
||||||
default:
|
default:
|
||||||
if descriptor.IsExtension() {
|
if descriptor.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterServiceResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterServiceResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterServiceResponse does not contain field %s", descriptor.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterServiceResponse does not contain field %s", descriptor.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1540,15 +1540,15 @@ func (x *fastReflection_MsgRegisterServiceResponse) Get(descriptor protoreflect.
|
|||||||
// Set is a mutating operation and unsafe for concurrent use.
|
// Set is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgRegisterServiceResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
func (x *fastReflection_MsgRegisterServiceResponse) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterServiceResponse.success":
|
case "svc.v1.MsgRegisterServiceResponse.success":
|
||||||
x.Success = value.Bool()
|
x.Success = value.Bool()
|
||||||
case "service.v1.MsgRegisterServiceResponse.did":
|
case "svc.v1.MsgRegisterServiceResponse.did":
|
||||||
x.Did = value.Interface().(string)
|
x.Did = value.Interface().(string)
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterServiceResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterServiceResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1564,15 +1564,15 @@ func (x *fastReflection_MsgRegisterServiceResponse) Set(fd protoreflect.FieldDes
|
|||||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
// Mutable is a mutating operation and unsafe for concurrent use.
|
||||||
func (x *fastReflection_MsgRegisterServiceResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgRegisterServiceResponse) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterServiceResponse.success":
|
case "svc.v1.MsgRegisterServiceResponse.success":
|
||||||
panic(fmt.Errorf("field success of message service.v1.MsgRegisterServiceResponse is not mutable"))
|
panic(fmt.Errorf("field success of message svc.v1.MsgRegisterServiceResponse is not mutable"))
|
||||||
case "service.v1.MsgRegisterServiceResponse.did":
|
case "svc.v1.MsgRegisterServiceResponse.did":
|
||||||
panic(fmt.Errorf("field did of message service.v1.MsgRegisterServiceResponse is not mutable"))
|
panic(fmt.Errorf("field did of message svc.v1.MsgRegisterServiceResponse is not mutable"))
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterServiceResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterServiceResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1581,15 +1581,15 @@ func (x *fastReflection_MsgRegisterServiceResponse) Mutable(fd protoreflect.Fiel
|
|||||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
||||||
func (x *fastReflection_MsgRegisterServiceResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
func (x *fastReflection_MsgRegisterServiceResponse) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
||||||
switch fd.FullName() {
|
switch fd.FullName() {
|
||||||
case "service.v1.MsgRegisterServiceResponse.success":
|
case "svc.v1.MsgRegisterServiceResponse.success":
|
||||||
return protoreflect.ValueOfBool(false)
|
return protoreflect.ValueOfBool(false)
|
||||||
case "service.v1.MsgRegisterServiceResponse.did":
|
case "svc.v1.MsgRegisterServiceResponse.did":
|
||||||
return protoreflect.ValueOfString("")
|
return protoreflect.ValueOfString("")
|
||||||
default:
|
default:
|
||||||
if fd.IsExtension() {
|
if fd.IsExtension() {
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: service.v1.MsgRegisterServiceResponse"))
|
panic(fmt.Errorf("proto3 declared messages do not support extensions: svc.v1.MsgRegisterServiceResponse"))
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("message service.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
panic(fmt.Errorf("message svc.v1.MsgRegisterServiceResponse does not contain field %s", fd.FullName()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1599,7 +1599,7 @@ func (x *fastReflection_MsgRegisterServiceResponse) NewField(fd protoreflect.Fie
|
|||||||
func (x *fastReflection_MsgRegisterServiceResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
func (x *fastReflection_MsgRegisterServiceResponse) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
||||||
switch d.FullName() {
|
switch d.FullName() {
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf("%s is not a oneof field in service.v1.MsgRegisterServiceResponse", d.FullName()))
|
panic(fmt.Errorf("%s is not a oneof field in svc.v1.MsgRegisterServiceResponse", d.FullName()))
|
||||||
}
|
}
|
||||||
panic("unreachable")
|
panic("unreachable")
|
||||||
}
|
}
|
||||||
@@ -1847,7 +1847,7 @@ func (x *fastReflection_MsgRegisterServiceResponse) ProtoMethods() *protoiface.M
|
|||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.27.0
|
// protoc-gen-go v1.27.0
|
||||||
// protoc (unknown)
|
// protoc (unknown)
|
||||||
// source: service/v1/tx.proto
|
// source: svc/v1/tx.proto
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
// Verify that this generated code is sufficiently up-to-date.
|
||||||
@@ -1875,7 +1875,7 @@ type MsgUpdateParams struct {
|
|||||||
func (x *MsgUpdateParams) Reset() {
|
func (x *MsgUpdateParams) Reset() {
|
||||||
*x = MsgUpdateParams{}
|
*x = MsgUpdateParams{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[0]
|
mi := &file_svc_v1_tx_proto_msgTypes[0]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1889,7 +1889,7 @@ func (*MsgUpdateParams) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use MsgUpdateParams.ProtoReflect.Descriptor instead.
|
// Deprecated: Use MsgUpdateParams.ProtoReflect.Descriptor instead.
|
||||||
func (*MsgUpdateParams) Descriptor() ([]byte, []int) {
|
func (*MsgUpdateParams) Descriptor() ([]byte, []int) {
|
||||||
return file_service_v1_tx_proto_rawDescGZIP(), []int{0}
|
return file_svc_v1_tx_proto_rawDescGZIP(), []int{0}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgUpdateParams) GetAuthority() string {
|
func (x *MsgUpdateParams) GetAuthority() string {
|
||||||
@@ -1919,7 +1919,7 @@ type MsgUpdateParamsResponse struct {
|
|||||||
func (x *MsgUpdateParamsResponse) Reset() {
|
func (x *MsgUpdateParamsResponse) Reset() {
|
||||||
*x = MsgUpdateParamsResponse{}
|
*x = MsgUpdateParamsResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[1]
|
mi := &file_svc_v1_tx_proto_msgTypes[1]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1933,7 +1933,7 @@ func (*MsgUpdateParamsResponse) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use MsgUpdateParamsResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use MsgUpdateParamsResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) {
|
func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_service_v1_tx_proto_rawDescGZIP(), []int{1}
|
return file_svc_v1_tx_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MsgRegisterService is the message type for the RegisterService RPC.
|
// MsgRegisterService is the message type for the RegisterService RPC.
|
||||||
@@ -1952,7 +1952,7 @@ type MsgRegisterService struct {
|
|||||||
func (x *MsgRegisterService) Reset() {
|
func (x *MsgRegisterService) Reset() {
|
||||||
*x = MsgRegisterService{}
|
*x = MsgRegisterService{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[2]
|
mi := &file_svc_v1_tx_proto_msgTypes[2]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -1966,7 +1966,7 @@ func (*MsgRegisterService) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use MsgRegisterService.ProtoReflect.Descriptor instead.
|
// Deprecated: Use MsgRegisterService.ProtoReflect.Descriptor instead.
|
||||||
func (*MsgRegisterService) Descriptor() ([]byte, []int) {
|
func (*MsgRegisterService) Descriptor() ([]byte, []int) {
|
||||||
return file_service_v1_tx_proto_rawDescGZIP(), []int{2}
|
return file_svc_v1_tx_proto_rawDescGZIP(), []int{2}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgRegisterService) GetController() string {
|
func (x *MsgRegisterService) GetController() string {
|
||||||
@@ -1996,7 +1996,7 @@ type MsgRegisterServiceResponse struct {
|
|||||||
func (x *MsgRegisterServiceResponse) Reset() {
|
func (x *MsgRegisterServiceResponse) Reset() {
|
||||||
*x = MsgRegisterServiceResponse{}
|
*x = MsgRegisterServiceResponse{}
|
||||||
if protoimpl.UnsafeEnabled {
|
if protoimpl.UnsafeEnabled {
|
||||||
mi := &file_service_v1_tx_proto_msgTypes[3]
|
mi := &file_svc_v1_tx_proto_msgTypes[3]
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
ms.StoreMessageInfo(mi)
|
ms.StoreMessageInfo(mi)
|
||||||
}
|
}
|
||||||
@@ -2010,7 +2010,7 @@ func (*MsgRegisterServiceResponse) ProtoMessage() {}
|
|||||||
|
|
||||||
// Deprecated: Use MsgRegisterServiceResponse.ProtoReflect.Descriptor instead.
|
// Deprecated: Use MsgRegisterServiceResponse.ProtoReflect.Descriptor instead.
|
||||||
func (*MsgRegisterServiceResponse) Descriptor() ([]byte, []int) {
|
func (*MsgRegisterServiceResponse) Descriptor() ([]byte, []int) {
|
||||||
return file_service_v1_tx_proto_rawDescGZIP(), []int{3}
|
return file_svc_v1_tx_proto_rawDescGZIP(), []int{3}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *MsgRegisterServiceResponse) GetSuccess() bool {
|
func (x *MsgRegisterServiceResponse) GetSuccess() bool {
|
||||||
@@ -2027,94 +2027,90 @@ func (x *MsgRegisterServiceResponse) GetDid() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
var File_service_v1_tx_proto protoreflect.FileDescriptor
|
var File_svc_v1_tx_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
var file_service_v1_tx_proto_rawDesc = []byte{
|
var file_svc_v1_tx_proto_rawDesc = []byte{
|
||||||
0x0a, 0x13, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x78, 0x2e,
|
0x0a, 0x0f, 0x73, 0x76, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76,
|
0x6f, 0x12, 0x06, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f,
|
||||||
0x31, 0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x76, 0x31,
|
0x73, 0x2f, 0x6d, 0x73, 0x67, 0x2f, 0x76, 0x31, 0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f,
|
||||||
0x2f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, 0x6d,
|
0x74, 0x6f, 0x1a, 0x14, 0x73, 0x76, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73,
|
||||||
0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e,
|
0x69, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x14, 0x67, 0x6f, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
0x6f, 0x74, 0x6f, 0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
|
||||||
0x2f, 0x67, 0x6f, 0x67, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x18, 0x73, 0x65, 0x72,
|
0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73,
|
||||||
0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x67, 0x65, 0x6e, 0x65, 0x73, 0x69, 0x73, 0x2e,
|
0x6d, 0x6f, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x87, 0x01, 0x0a, 0x0f, 0x4d, 0x73,
|
||||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x8b, 0x01, 0x0a, 0x0f, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64,
|
0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a,
|
||||||
0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x36, 0x0a, 0x09, 0x61, 0x75, 0x74,
|
0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x68, 0x6f, 0x72, 0x69, 0x74, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4,
|
0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64,
|
||||||
0x2d, 0x14, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73,
|
0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68,
|
||||||
0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74,
|
0x6f, 0x72, 0x69, 0x74, 0x79, 0x12, 0x2c, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18,
|
||||||
0x79, 0x12, 0x30, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28,
|
0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x50,
|
||||||
0x0b, 0x32, 0x12, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x50,
|
|
||||||
0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x61, 0x72,
|
0x61, 0x72, 0x61, 0x6d, 0x73, 0x42, 0x04, 0xc8, 0xde, 0x1f, 0x00, 0x52, 0x06, 0x70, 0x61, 0x72,
|
||||||
0x61, 0x6d, 0x73, 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
0x61, 0x6d, 0x73, 0x3a, 0x0e, 0x82, 0xe7, 0xb0, 0x2a, 0x09, 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72,
|
||||||
0x69, 0x74, 0x79, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
|
0x69, 0x74, 0x79, 0x22, 0x19, 0x0a, 0x17, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
|
||||||
0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8e,
|
0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x8a,
|
||||||
0x01, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65,
|
0x01, 0x0a, 0x12, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x38, 0x0a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c,
|
||||||
0x6c, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63,
|
0x6c, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x18, 0xd2, 0xb4, 0x2d, 0x14, 0x63,
|
||||||
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72,
|
0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x53, 0x74, 0x72,
|
||||||
0x69, 0x6e, 0x67, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12,
|
0x69, 0x6e, 0x67, 0x52, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x12,
|
||||||
0x2d, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
0x29, 0x0a, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b,
|
||||||
0x32, 0x13, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65,
|
0x32, 0x0f, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x3a, 0x0f,
|
0x65, 0x52, 0x07, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x3a, 0x0f, 0x82, 0xe7, 0xb0, 0x2a,
|
||||||
0x82, 0xe7, 0xb0, 0x2a, 0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x22,
|
0x0a, 0x63, 0x6f, 0x6e, 0x74, 0x72, 0x6f, 0x6c, 0x6c, 0x65, 0x72, 0x22, 0x48, 0x0a, 0x1a, 0x4d,
|
||||||
0x48, 0x0a, 0x1a, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65,
|
0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a,
|
0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63,
|
||||||
0x07, 0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07,
|
0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63,
|
||||||
0x73, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, 0x64, 0x18, 0x02,
|
0x65, 0x73, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x64, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x64, 0x69, 0x64, 0x32, 0xb9, 0x01, 0x0a, 0x03, 0x4d, 0x73,
|
0x52, 0x03, 0x64, 0x69, 0x64, 0x32, 0xa9, 0x01, 0x0a, 0x03, 0x4d, 0x73, 0x67, 0x12, 0x48, 0x0a,
|
||||||
0x67, 0x12, 0x50, 0x0a, 0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d,
|
0x0c, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x17, 0x2e,
|
||||||
0x73, 0x12, 0x1b, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d,
|
0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65,
|
||||||
0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x23,
|
0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x1a, 0x1f, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e,
|
||||||
0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x55,
|
0x4d, 0x73, 0x67, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52,
|
||||||
0x70, 0x64, 0x61, 0x74, 0x65, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f,
|
0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x51, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73,
|
||||||
0x6e, 0x73, 0x65, 0x12, 0x59, 0x0a, 0x0f, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53,
|
0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1a, 0x2e, 0x73, 0x76, 0x63,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x1e, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
|
||||||
0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53,
|
0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x26, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1a, 0x22, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x2e,
|
||||||
0x2e, 0x76, 0x31, 0x2e, 0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53,
|
0x4d, 0x73, 0x67, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69,
|
||||||
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05,
|
0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x1a, 0x05, 0x80, 0xe7, 0xb0, 0x2a,
|
||||||
0x80, 0xe7, 0xb0, 0x2a, 0x01, 0x42, 0x93, 0x01, 0x0a, 0x0e, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x65,
|
0x01, 0x42, 0x77, 0x0a, 0x0a, 0x63, 0x6f, 0x6d, 0x2e, 0x73, 0x76, 0x63, 0x2e, 0x76, 0x31, 0x42,
|
||||||
0x72, 0x76, 0x69, 0x63, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74,
|
0x07, 0x54, 0x78, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x27, 0x67, 0x69, 0x74, 0x68,
|
||||||
0x6f, 0x50, 0x01, 0x5a, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
|
0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f,
|
||||||
0x6f, 0x6e, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f,
|
0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x73, 0x76, 0x63, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x76,
|
||||||
0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x69,
|
0x63, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x06, 0x53, 0x76, 0x63, 0x2e,
|
||||||
0x63, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x53, 0x58, 0x58, 0xaa, 0x02, 0x0a, 0x53, 0x65, 0x72,
|
0x56, 0x31, 0xca, 0x02, 0x06, 0x53, 0x76, 0x63, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x12, 0x53, 0x76,
|
||||||
0x76, 0x69, 0x63, 0x65, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x0a, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
|
0x63, 0x5c, 0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
|
||||||
0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x16, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5c, 0x56,
|
0xea, 0x02, 0x07, 0x53, 0x76, 0x63, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||||
0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0b,
|
0x6f, 0x33,
|
||||||
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
|
||||||
0x74, 0x6f, 0x33,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
file_service_v1_tx_proto_rawDescOnce sync.Once
|
file_svc_v1_tx_proto_rawDescOnce sync.Once
|
||||||
file_service_v1_tx_proto_rawDescData = file_service_v1_tx_proto_rawDesc
|
file_svc_v1_tx_proto_rawDescData = file_svc_v1_tx_proto_rawDesc
|
||||||
)
|
)
|
||||||
|
|
||||||
func file_service_v1_tx_proto_rawDescGZIP() []byte {
|
func file_svc_v1_tx_proto_rawDescGZIP() []byte {
|
||||||
file_service_v1_tx_proto_rawDescOnce.Do(func() {
|
file_svc_v1_tx_proto_rawDescOnce.Do(func() {
|
||||||
file_service_v1_tx_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_v1_tx_proto_rawDescData)
|
file_svc_v1_tx_proto_rawDescData = protoimpl.X.CompressGZIP(file_svc_v1_tx_proto_rawDescData)
|
||||||
})
|
})
|
||||||
return file_service_v1_tx_proto_rawDescData
|
return file_svc_v1_tx_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_service_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
var file_svc_v1_tx_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||||
var file_service_v1_tx_proto_goTypes = []interface{}{
|
var file_svc_v1_tx_proto_goTypes = []interface{}{
|
||||||
(*MsgUpdateParams)(nil), // 0: service.v1.MsgUpdateParams
|
(*MsgUpdateParams)(nil), // 0: svc.v1.MsgUpdateParams
|
||||||
(*MsgUpdateParamsResponse)(nil), // 1: service.v1.MsgUpdateParamsResponse
|
(*MsgUpdateParamsResponse)(nil), // 1: svc.v1.MsgUpdateParamsResponse
|
||||||
(*MsgRegisterService)(nil), // 2: service.v1.MsgRegisterService
|
(*MsgRegisterService)(nil), // 2: svc.v1.MsgRegisterService
|
||||||
(*MsgRegisterServiceResponse)(nil), // 3: service.v1.MsgRegisterServiceResponse
|
(*MsgRegisterServiceResponse)(nil), // 3: svc.v1.MsgRegisterServiceResponse
|
||||||
(*Params)(nil), // 4: service.v1.Params
|
(*Params)(nil), // 4: svc.v1.Params
|
||||||
(*Service)(nil), // 5: service.v1.Service
|
(*Service)(nil), // 5: svc.v1.Service
|
||||||
}
|
}
|
||||||
var file_service_v1_tx_proto_depIdxs = []int32{
|
var file_svc_v1_tx_proto_depIdxs = []int32{
|
||||||
4, // 0: service.v1.MsgUpdateParams.params:type_name -> service.v1.Params
|
4, // 0: svc.v1.MsgUpdateParams.params:type_name -> svc.v1.Params
|
||||||
5, // 1: service.v1.MsgRegisterService.service:type_name -> service.v1.Service
|
5, // 1: svc.v1.MsgRegisterService.service:type_name -> svc.v1.Service
|
||||||
0, // 2: service.v1.Msg.UpdateParams:input_type -> service.v1.MsgUpdateParams
|
0, // 2: svc.v1.Msg.UpdateParams:input_type -> svc.v1.MsgUpdateParams
|
||||||
2, // 3: service.v1.Msg.RegisterService:input_type -> service.v1.MsgRegisterService
|
2, // 3: svc.v1.Msg.RegisterService:input_type -> svc.v1.MsgRegisterService
|
||||||
1, // 4: service.v1.Msg.UpdateParams:output_type -> service.v1.MsgUpdateParamsResponse
|
1, // 4: svc.v1.Msg.UpdateParams:output_type -> svc.v1.MsgUpdateParamsResponse
|
||||||
3, // 5: service.v1.Msg.RegisterService:output_type -> service.v1.MsgRegisterServiceResponse
|
3, // 5: svc.v1.Msg.RegisterService:output_type -> svc.v1.MsgRegisterServiceResponse
|
||||||
4, // [4:6] is the sub-list for method output_type
|
4, // [4:6] is the sub-list for method output_type
|
||||||
2, // [2:4] is the sub-list for method input_type
|
2, // [2:4] is the sub-list for method input_type
|
||||||
2, // [2:2] is the sub-list for extension type_name
|
2, // [2:2] is the sub-list for extension type_name
|
||||||
@@ -2122,14 +2118,14 @@ var file_service_v1_tx_proto_depIdxs = []int32{
|
|||||||
0, // [0:2] is the sub-list for field type_name
|
0, // [0:2] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_service_v1_tx_proto_init() }
|
func init() { file_svc_v1_tx_proto_init() }
|
||||||
func file_service_v1_tx_proto_init() {
|
func file_svc_v1_tx_proto_init() {
|
||||||
if File_service_v1_tx_proto != nil {
|
if File_svc_v1_tx_proto != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
file_service_v1_genesis_proto_init()
|
file_svc_v1_genesis_proto_init()
|
||||||
if !protoimpl.UnsafeEnabled {
|
if !protoimpl.UnsafeEnabled {
|
||||||
file_service_v1_tx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_v1_tx_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*MsgUpdateParams); i {
|
switch v := v.(*MsgUpdateParams); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -2141,7 +2137,7 @@ func file_service_v1_tx_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_service_v1_tx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_v1_tx_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*MsgUpdateParamsResponse); i {
|
switch v := v.(*MsgUpdateParamsResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -2153,7 +2149,7 @@ func file_service_v1_tx_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_service_v1_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_v1_tx_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*MsgRegisterService); i {
|
switch v := v.(*MsgRegisterService); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -2165,7 +2161,7 @@ func file_service_v1_tx_proto_init() {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_service_v1_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
file_svc_v1_tx_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||||
switch v := v.(*MsgRegisterServiceResponse); i {
|
switch v := v.(*MsgRegisterServiceResponse); i {
|
||||||
case 0:
|
case 0:
|
||||||
return &v.state
|
return &v.state
|
||||||
@@ -2182,18 +2178,18 @@ func file_service_v1_tx_proto_init() {
|
|||||||
out := protoimpl.TypeBuilder{
|
out := protoimpl.TypeBuilder{
|
||||||
File: protoimpl.DescBuilder{
|
File: protoimpl.DescBuilder{
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: file_service_v1_tx_proto_rawDesc,
|
RawDescriptor: file_svc_v1_tx_proto_rawDesc,
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 4,
|
NumMessages: 4,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
GoTypes: file_service_v1_tx_proto_goTypes,
|
GoTypes: file_svc_v1_tx_proto_goTypes,
|
||||||
DependencyIndexes: file_service_v1_tx_proto_depIdxs,
|
DependencyIndexes: file_svc_v1_tx_proto_depIdxs,
|
||||||
MessageInfos: file_service_v1_tx_proto_msgTypes,
|
MessageInfos: file_svc_v1_tx_proto_msgTypes,
|
||||||
}.Build()
|
}.Build()
|
||||||
File_service_v1_tx_proto = out.File
|
File_svc_v1_tx_proto = out.File
|
||||||
file_service_v1_tx_proto_rawDesc = nil
|
file_svc_v1_tx_proto_rawDesc = nil
|
||||||
file_service_v1_tx_proto_goTypes = nil
|
file_svc_v1_tx_proto_goTypes = nil
|
||||||
file_service_v1_tx_proto_depIdxs = nil
|
file_svc_v1_tx_proto_depIdxs = nil
|
||||||
}
|
}
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
// versions:
|
// versions:
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
// - protoc-gen-go-grpc v1.5.1
|
||||||
// - protoc (unknown)
|
// - protoc (unknown)
|
||||||
// source: service/v1/tx.proto
|
// source: svc/v1/tx.proto
|
||||||
|
|
||||||
package servicev1
|
package svcv1
|
||||||
|
|
||||||
import (
|
import (
|
||||||
context "context"
|
context "context"
|
||||||
@@ -19,8 +19,8 @@ import (
|
|||||||
const _ = grpc.SupportPackageIsVersion9
|
const _ = grpc.SupportPackageIsVersion9
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Msg_UpdateParams_FullMethodName = "/service.v1.Msg/UpdateParams"
|
Msg_UpdateParams_FullMethodName = "/svc.v1.Msg/UpdateParams"
|
||||||
Msg_RegisterService_FullMethodName = "/service.v1.Msg/RegisterService"
|
Msg_RegisterService_FullMethodName = "/svc.v1.Msg/RegisterService"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgClient is the client API for Msg service.
|
// MsgClient is the client API for Msg service.
|
||||||
@@ -156,7 +156,7 @@ func _Msg_RegisterService_Handler(srv interface{}, ctx context.Context, dec func
|
|||||||
// It's only intended for direct use with grpc.RegisterService,
|
// It's only intended for direct use with grpc.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
var Msg_ServiceDesc = grpc.ServiceDesc{
|
var Msg_ServiceDesc = grpc.ServiceDesc{
|
||||||
ServiceName: "service.v1.Msg",
|
ServiceName: "svc.v1.Msg",
|
||||||
HandlerType: (*MsgServer)(nil),
|
HandlerType: (*MsgServer)(nil),
|
||||||
Methods: []grpc.MethodDesc{
|
Methods: []grpc.MethodDesc{
|
||||||
{
|
{
|
||||||
@@ -169,5 +169,5 @@ var Msg_ServiceDesc = grpc.ServiceDesc{
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc.StreamDesc{},
|
Streams: []grpc.StreamDesc{},
|
||||||
Metadata: "service/v1/tx.proto",
|
Metadata: "svc/v1/tx.proto",
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,235 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
|
|
||||||
|
|
||||||
package vaultv1
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
ormlist "cosmossdk.io/orm/model/ormlist"
|
|
||||||
ormtable "cosmossdk.io/orm/model/ormtable"
|
|
||||||
ormerrors "cosmossdk.io/orm/types/ormerrors"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DWNTable interface {
|
|
||||||
Insert(ctx context.Context, dWN *DWN) error
|
|
||||||
InsertReturningId(ctx context.Context, dWN *DWN) (uint64, error)
|
|
||||||
LastInsertedSequence(ctx context.Context) (uint64, error)
|
|
||||||
Update(ctx context.Context, dWN *DWN) error
|
|
||||||
Save(ctx context.Context, dWN *DWN) error
|
|
||||||
Delete(ctx context.Context, dWN *DWN) error
|
|
||||||
Has(ctx context.Context, id uint64) (found bool, err error)
|
|
||||||
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
Get(ctx context.Context, id uint64) (*DWN, error)
|
|
||||||
HasByAlias(ctx context.Context, alias string) (found bool, err error)
|
|
||||||
// GetByAlias returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
GetByAlias(ctx context.Context, alias string) (*DWN, error)
|
|
||||||
HasByCid(ctx context.Context, cid string) (found bool, err error)
|
|
||||||
// GetByCid returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
|
|
||||||
GetByCid(ctx context.Context, cid string) (*DWN, error)
|
|
||||||
List(ctx context.Context, prefixKey DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error)
|
|
||||||
ListRange(ctx context.Context, from, to DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error)
|
|
||||||
DeleteBy(ctx context.Context, prefixKey DWNIndexKey) error
|
|
||||||
DeleteRange(ctx context.Context, from, to DWNIndexKey) error
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type DWNIterator struct {
|
|
||||||
ormtable.Iterator
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i DWNIterator) Value() (*DWN, error) {
|
|
||||||
var dWN DWN
|
|
||||||
err := i.UnmarshalMessage(&dWN)
|
|
||||||
return &dWN, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type DWNIndexKey interface {
|
|
||||||
id() uint32
|
|
||||||
values() []interface{}
|
|
||||||
dWNIndexKey()
|
|
||||||
}
|
|
||||||
|
|
||||||
// primary key starting index..
|
|
||||||
type DWNPrimaryKey = DWNIdIndexKey
|
|
||||||
|
|
||||||
type DWNIdIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x DWNIdIndexKey) id() uint32 { return 0 }
|
|
||||||
func (x DWNIdIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x DWNIdIndexKey) dWNIndexKey() {}
|
|
||||||
|
|
||||||
func (this DWNIdIndexKey) WithId(id uint64) DWNIdIndexKey {
|
|
||||||
this.vs = []interface{}{id}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type DWNAliasIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x DWNAliasIndexKey) id() uint32 { return 1 }
|
|
||||||
func (x DWNAliasIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x DWNAliasIndexKey) dWNIndexKey() {}
|
|
||||||
|
|
||||||
func (this DWNAliasIndexKey) WithAlias(alias string) DWNAliasIndexKey {
|
|
||||||
this.vs = []interface{}{alias}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type DWNCidIndexKey struct {
|
|
||||||
vs []interface{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x DWNCidIndexKey) id() uint32 { return 2 }
|
|
||||||
func (x DWNCidIndexKey) values() []interface{} { return x.vs }
|
|
||||||
func (x DWNCidIndexKey) dWNIndexKey() {}
|
|
||||||
|
|
||||||
func (this DWNCidIndexKey) WithCid(cid string) DWNCidIndexKey {
|
|
||||||
this.vs = []interface{}{cid}
|
|
||||||
return this
|
|
||||||
}
|
|
||||||
|
|
||||||
type dWNTable struct {
|
|
||||||
table ormtable.AutoIncrementTable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) Insert(ctx context.Context, dWN *DWN) error {
|
|
||||||
return this.table.Insert(ctx, dWN)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) Update(ctx context.Context, dWN *DWN) error {
|
|
||||||
return this.table.Update(ctx, dWN)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) Save(ctx context.Context, dWN *DWN) error {
|
|
||||||
return this.table.Save(ctx, dWN)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) Delete(ctx context.Context, dWN *DWN) error {
|
|
||||||
return this.table.Delete(ctx, dWN)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) InsertReturningId(ctx context.Context, dWN *DWN) (uint64, error) {
|
|
||||||
return this.table.InsertReturningPKey(ctx, dWN)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) LastInsertedSequence(ctx context.Context) (uint64, error) {
|
|
||||||
return this.table.LastInsertedSequence(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) Has(ctx context.Context, id uint64) (found bool, err error) {
|
|
||||||
return this.table.PrimaryKey().Has(ctx, id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) Get(ctx context.Context, id uint64) (*DWN, error) {
|
|
||||||
var dWN DWN
|
|
||||||
found, err := this.table.PrimaryKey().Get(ctx, &dWN, id)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &dWN, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) HasByAlias(ctx context.Context, alias string) (found bool, err error) {
|
|
||||||
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
|
|
||||||
alias,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) GetByAlias(ctx context.Context, alias string) (*DWN, error) {
|
|
||||||
var dWN DWN
|
|
||||||
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &dWN,
|
|
||||||
alias,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &dWN, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) HasByCid(ctx context.Context, cid string) (found bool, err error) {
|
|
||||||
return this.table.GetIndexByID(2).(ormtable.UniqueIndex).Has(ctx,
|
|
||||||
cid,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) GetByCid(ctx context.Context, cid string) (*DWN, error) {
|
|
||||||
var dWN DWN
|
|
||||||
found, err := this.table.GetIndexByID(2).(ormtable.UniqueIndex).Get(ctx, &dWN,
|
|
||||||
cid,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if !found {
|
|
||||||
return nil, ormerrors.NotFound
|
|
||||||
}
|
|
||||||
return &dWN, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) List(ctx context.Context, prefixKey DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
|
|
||||||
return DWNIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) ListRange(ctx context.Context, from, to DWNIndexKey, opts ...ormlist.Option) (DWNIterator, error) {
|
|
||||||
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
|
|
||||||
return DWNIterator{it}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) DeleteBy(ctx context.Context, prefixKey DWNIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) DeleteRange(ctx context.Context, from, to DWNIndexKey) error {
|
|
||||||
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (this dWNTable) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ DWNTable = dWNTable{}
|
|
||||||
|
|
||||||
func NewDWNTable(db ormtable.Schema) (DWNTable, error) {
|
|
||||||
table := db.GetTable(&DWN{})
|
|
||||||
if table == nil {
|
|
||||||
return nil, ormerrors.TableNotFound.Wrap(string((&DWN{}).ProtoReflect().Descriptor().FullName()))
|
|
||||||
}
|
|
||||||
return dWNTable{table.(ormtable.AutoIncrementTable)}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
type StateStore interface {
|
|
||||||
DWNTable() DWNTable
|
|
||||||
|
|
||||||
doNotImplement()
|
|
||||||
}
|
|
||||||
|
|
||||||
type stateStore struct {
|
|
||||||
dWN DWNTable
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x stateStore) DWNTable() DWNTable {
|
|
||||||
return x.dWN
|
|
||||||
}
|
|
||||||
|
|
||||||
func (stateStore) doNotImplement() {}
|
|
||||||
|
|
||||||
var _ StateStore = stateStore{}
|
|
||||||
|
|
||||||
func NewStateStore(db ormtable.Schema) (StateStore, error) {
|
|
||||||
dWNTable, err := NewDWNTable(db)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return stateStore{
|
|
||||||
dWNTable,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
@@ -1,772 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-pulsar. DO NOT EDIT.
|
|
||||||
package vaultv1
|
|
||||||
|
|
||||||
import (
|
|
||||||
_ "cosmossdk.io/api/cosmos/orm/v1"
|
|
||||||
fmt "fmt"
|
|
||||||
runtime "github.com/cosmos/cosmos-proto/runtime"
|
|
||||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
||||||
protoiface "google.golang.org/protobuf/runtime/protoiface"
|
|
||||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
||||||
io "io"
|
|
||||||
reflect "reflect"
|
|
||||||
sync "sync"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
md_DWN protoreflect.MessageDescriptor
|
|
||||||
fd_DWN_id protoreflect.FieldDescriptor
|
|
||||||
fd_DWN_alias protoreflect.FieldDescriptor
|
|
||||||
fd_DWN_cid protoreflect.FieldDescriptor
|
|
||||||
fd_DWN_resolver protoreflect.FieldDescriptor
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
file_vault_v1_state_proto_init()
|
|
||||||
md_DWN = File_vault_v1_state_proto.Messages().ByName("DWN")
|
|
||||||
fd_DWN_id = md_DWN.Fields().ByName("id")
|
|
||||||
fd_DWN_alias = md_DWN.Fields().ByName("alias")
|
|
||||||
fd_DWN_cid = md_DWN.Fields().ByName("cid")
|
|
||||||
fd_DWN_resolver = md_DWN.Fields().ByName("resolver")
|
|
||||||
}
|
|
||||||
|
|
||||||
var _ protoreflect.Message = (*fastReflection_DWN)(nil)
|
|
||||||
|
|
||||||
type fastReflection_DWN DWN
|
|
||||||
|
|
||||||
func (x *DWN) ProtoReflect() protoreflect.Message {
|
|
||||||
return (*fastReflection_DWN)(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) slowProtoReflect() protoreflect.Message {
|
|
||||||
mi := &file_vault_v1_state_proto_msgTypes[0]
|
|
||||||
if protoimpl.UnsafeEnabled && x != nil {
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
if ms.LoadMessageInfo() == nil {
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
return ms
|
|
||||||
}
|
|
||||||
return mi.MessageOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
var _fastReflection_DWN_messageType fastReflection_DWN_messageType
|
|
||||||
var _ protoreflect.MessageType = fastReflection_DWN_messageType{}
|
|
||||||
|
|
||||||
type fastReflection_DWN_messageType struct{}
|
|
||||||
|
|
||||||
func (x fastReflection_DWN_messageType) Zero() protoreflect.Message {
|
|
||||||
return (*fastReflection_DWN)(nil)
|
|
||||||
}
|
|
||||||
func (x fastReflection_DWN_messageType) New() protoreflect.Message {
|
|
||||||
return new(fastReflection_DWN)
|
|
||||||
}
|
|
||||||
func (x fastReflection_DWN_messageType) Descriptor() protoreflect.MessageDescriptor {
|
|
||||||
return md_DWN
|
|
||||||
}
|
|
||||||
|
|
||||||
// Descriptor returns message descriptor, which contains only the protobuf
|
|
||||||
// type information for the message.
|
|
||||||
func (x *fastReflection_DWN) Descriptor() protoreflect.MessageDescriptor {
|
|
||||||
return md_DWN
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type returns the message type, which encapsulates both Go and protobuf
|
|
||||||
// type information. If the Go type information is not needed,
|
|
||||||
// it is recommended that the message descriptor be used instead.
|
|
||||||
func (x *fastReflection_DWN) Type() protoreflect.MessageType {
|
|
||||||
return _fastReflection_DWN_messageType
|
|
||||||
}
|
|
||||||
|
|
||||||
// New returns a newly allocated and mutable empty message.
|
|
||||||
func (x *fastReflection_DWN) New() protoreflect.Message {
|
|
||||||
return new(fastReflection_DWN)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interface unwraps the message reflection interface and
|
|
||||||
// returns the underlying ProtoMessage interface.
|
|
||||||
func (x *fastReflection_DWN) Interface() protoreflect.ProtoMessage {
|
|
||||||
return (*DWN)(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Range iterates over every populated field in an undefined order,
|
|
||||||
// calling f for each field descriptor and value encountered.
|
|
||||||
// Range returns immediately if f returns false.
|
|
||||||
// While iterating, mutating operations may only be performed
|
|
||||||
// on the current field descriptor.
|
|
||||||
func (x *fastReflection_DWN) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) {
|
|
||||||
if x.Id != uint64(0) {
|
|
||||||
value := protoreflect.ValueOfUint64(x.Id)
|
|
||||||
if !f(fd_DWN_id, value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if x.Alias != "" {
|
|
||||||
value := protoreflect.ValueOfString(x.Alias)
|
|
||||||
if !f(fd_DWN_alias, value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if x.Cid != "" {
|
|
||||||
value := protoreflect.ValueOfString(x.Cid)
|
|
||||||
if !f(fd_DWN_cid, value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if x.Resolver != "" {
|
|
||||||
value := protoreflect.ValueOfString(x.Resolver)
|
|
||||||
if !f(fd_DWN_resolver, value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Has reports whether a field is populated.
|
|
||||||
//
|
|
||||||
// Some fields have the property of nullability where it is possible to
|
|
||||||
// distinguish between the default value of a field and whether the field
|
|
||||||
// was explicitly populated with the default value. Singular message fields,
|
|
||||||
// member fields of a oneof, and proto2 scalar fields are nullable. Such
|
|
||||||
// fields are populated only if explicitly set.
|
|
||||||
//
|
|
||||||
// In other cases (aside from the nullable cases above),
|
|
||||||
// a proto3 scalar field is populated if it contains a non-zero value, and
|
|
||||||
// a repeated field is populated if it is non-empty.
|
|
||||||
func (x *fastReflection_DWN) Has(fd protoreflect.FieldDescriptor) bool {
|
|
||||||
switch fd.FullName() {
|
|
||||||
case "vault.v1.DWN.id":
|
|
||||||
return x.Id != uint64(0)
|
|
||||||
case "vault.v1.DWN.alias":
|
|
||||||
return x.Alias != ""
|
|
||||||
case "vault.v1.DWN.cid":
|
|
||||||
return x.Cid != ""
|
|
||||||
case "vault.v1.DWN.resolver":
|
|
||||||
return x.Resolver != ""
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: vault.v1.DWN"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message vault.v1.DWN does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear clears the field such that a subsequent Has call reports false.
|
|
||||||
//
|
|
||||||
// Clearing an extension field clears both the extension type and value
|
|
||||||
// associated with the given field number.
|
|
||||||
//
|
|
||||||
// Clear is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_DWN) Clear(fd protoreflect.FieldDescriptor) {
|
|
||||||
switch fd.FullName() {
|
|
||||||
case "vault.v1.DWN.id":
|
|
||||||
x.Id = uint64(0)
|
|
||||||
case "vault.v1.DWN.alias":
|
|
||||||
x.Alias = ""
|
|
||||||
case "vault.v1.DWN.cid":
|
|
||||||
x.Cid = ""
|
|
||||||
case "vault.v1.DWN.resolver":
|
|
||||||
x.Resolver = ""
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: vault.v1.DWN"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message vault.v1.DWN does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get retrieves the value for a field.
|
|
||||||
//
|
|
||||||
// For unpopulated scalars, it returns the default value, where
|
|
||||||
// the default value of a bytes scalar is guaranteed to be a copy.
|
|
||||||
// For unpopulated composite types, it returns an empty, read-only view
|
|
||||||
// of the value; to obtain a mutable reference, use Mutable.
|
|
||||||
func (x *fastReflection_DWN) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value {
|
|
||||||
switch descriptor.FullName() {
|
|
||||||
case "vault.v1.DWN.id":
|
|
||||||
value := x.Id
|
|
||||||
return protoreflect.ValueOfUint64(value)
|
|
||||||
case "vault.v1.DWN.alias":
|
|
||||||
value := x.Alias
|
|
||||||
return protoreflect.ValueOfString(value)
|
|
||||||
case "vault.v1.DWN.cid":
|
|
||||||
value := x.Cid
|
|
||||||
return protoreflect.ValueOfString(value)
|
|
||||||
case "vault.v1.DWN.resolver":
|
|
||||||
value := x.Resolver
|
|
||||||
return protoreflect.ValueOfString(value)
|
|
||||||
default:
|
|
||||||
if descriptor.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: vault.v1.DWN"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message vault.v1.DWN does not contain field %s", descriptor.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set stores the value for a field.
|
|
||||||
//
|
|
||||||
// For a field belonging to a oneof, it implicitly clears any other field
|
|
||||||
// that may be currently set within the same oneof.
|
|
||||||
// For extension fields, it implicitly stores the provided ExtensionType.
|
|
||||||
// When setting a composite type, it is unspecified whether the stored value
|
|
||||||
// aliases the source's memory in any way. If the composite value is an
|
|
||||||
// empty, read-only value, then it panics.
|
|
||||||
//
|
|
||||||
// Set is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_DWN) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) {
|
|
||||||
switch fd.FullName() {
|
|
||||||
case "vault.v1.DWN.id":
|
|
||||||
x.Id = value.Uint()
|
|
||||||
case "vault.v1.DWN.alias":
|
|
||||||
x.Alias = value.Interface().(string)
|
|
||||||
case "vault.v1.DWN.cid":
|
|
||||||
x.Cid = value.Interface().(string)
|
|
||||||
case "vault.v1.DWN.resolver":
|
|
||||||
x.Resolver = value.Interface().(string)
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: vault.v1.DWN"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message vault.v1.DWN does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mutable returns a mutable reference to a composite type.
|
|
||||||
//
|
|
||||||
// If the field is unpopulated, it may allocate a composite value.
|
|
||||||
// For a field belonging to a oneof, it implicitly clears any other field
|
|
||||||
// that may be currently set within the same oneof.
|
|
||||||
// For extension fields, it implicitly stores the provided ExtensionType
|
|
||||||
// if not already stored.
|
|
||||||
// It panics if the field does not contain a composite type.
|
|
||||||
//
|
|
||||||
// Mutable is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_DWN) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
|
||||||
switch fd.FullName() {
|
|
||||||
case "vault.v1.DWN.id":
|
|
||||||
panic(fmt.Errorf("field id of message vault.v1.DWN is not mutable"))
|
|
||||||
case "vault.v1.DWN.alias":
|
|
||||||
panic(fmt.Errorf("field alias of message vault.v1.DWN is not mutable"))
|
|
||||||
case "vault.v1.DWN.cid":
|
|
||||||
panic(fmt.Errorf("field cid of message vault.v1.DWN is not mutable"))
|
|
||||||
case "vault.v1.DWN.resolver":
|
|
||||||
panic(fmt.Errorf("field resolver of message vault.v1.DWN is not mutable"))
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: vault.v1.DWN"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message vault.v1.DWN does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewField returns a new value that is assignable to the field
|
|
||||||
// for the given descriptor. For scalars, this returns the default value.
|
|
||||||
// For lists, maps, and messages, this returns a new, empty, mutable value.
|
|
||||||
func (x *fastReflection_DWN) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value {
|
|
||||||
switch fd.FullName() {
|
|
||||||
case "vault.v1.DWN.id":
|
|
||||||
return protoreflect.ValueOfUint64(uint64(0))
|
|
||||||
case "vault.v1.DWN.alias":
|
|
||||||
return protoreflect.ValueOfString("")
|
|
||||||
case "vault.v1.DWN.cid":
|
|
||||||
return protoreflect.ValueOfString("")
|
|
||||||
case "vault.v1.DWN.resolver":
|
|
||||||
return protoreflect.ValueOfString("")
|
|
||||||
default:
|
|
||||||
if fd.IsExtension() {
|
|
||||||
panic(fmt.Errorf("proto3 declared messages do not support extensions: vault.v1.DWN"))
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("message vault.v1.DWN does not contain field %s", fd.FullName()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WhichOneof reports which field within the oneof is populated,
|
|
||||||
// returning nil if none are populated.
|
|
||||||
// It panics if the oneof descriptor does not belong to this message.
|
|
||||||
func (x *fastReflection_DWN) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor {
|
|
||||||
switch d.FullName() {
|
|
||||||
default:
|
|
||||||
panic(fmt.Errorf("%s is not a oneof field in vault.v1.DWN", d.FullName()))
|
|
||||||
}
|
|
||||||
panic("unreachable")
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetUnknown retrieves the entire list of unknown fields.
|
|
||||||
// The caller may only mutate the contents of the RawFields
|
|
||||||
// if the mutated bytes are stored back into the message with SetUnknown.
|
|
||||||
func (x *fastReflection_DWN) GetUnknown() protoreflect.RawFields {
|
|
||||||
return x.unknownFields
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetUnknown stores an entire list of unknown fields.
|
|
||||||
// The raw fields must be syntactically valid according to the wire format.
|
|
||||||
// An implementation may panic if this is not the case.
|
|
||||||
// Once stored, the caller must not mutate the content of the RawFields.
|
|
||||||
// An empty RawFields may be passed to clear the fields.
|
|
||||||
//
|
|
||||||
// SetUnknown is a mutating operation and unsafe for concurrent use.
|
|
||||||
func (x *fastReflection_DWN) SetUnknown(fields protoreflect.RawFields) {
|
|
||||||
x.unknownFields = fields
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsValid reports whether the message is valid.
|
|
||||||
//
|
|
||||||
// An invalid message is an empty, read-only value.
|
|
||||||
//
|
|
||||||
// An invalid message often corresponds to a nil pointer of the concrete
|
|
||||||
// message type, but the details are implementation dependent.
|
|
||||||
// Validity is not part of the protobuf data model, and may not
|
|
||||||
// be preserved in marshaling or other operations.
|
|
||||||
func (x *fastReflection_DWN) IsValid() bool {
|
|
||||||
return x != nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations.
|
|
||||||
// This method may return nil.
|
|
||||||
//
|
|
||||||
// The returned methods type is identical to
|
|
||||||
// "google.golang.org/protobuf/runtime/protoiface".Methods.
|
|
||||||
// Consult the protoiface package documentation for details.
|
|
||||||
func (x *fastReflection_DWN) ProtoMethods() *protoiface.Methods {
|
|
||||||
size := func(input protoiface.SizeInput) protoiface.SizeOutput {
|
|
||||||
x := input.Message.Interface().(*DWN)
|
|
||||||
if x == nil {
|
|
||||||
return protoiface.SizeOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Size: 0,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
options := runtime.SizeInputToOptions(input)
|
|
||||||
_ = options
|
|
||||||
var n int
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
if x.Id != 0 {
|
|
||||||
n += 1 + runtime.Sov(uint64(x.Id))
|
|
||||||
}
|
|
||||||
l = len(x.Alias)
|
|
||||||
if l > 0 {
|
|
||||||
n += 1 + l + runtime.Sov(uint64(l))
|
|
||||||
}
|
|
||||||
l = len(x.Cid)
|
|
||||||
if l > 0 {
|
|
||||||
n += 1 + l + runtime.Sov(uint64(l))
|
|
||||||
}
|
|
||||||
l = len(x.Resolver)
|
|
||||||
if l > 0 {
|
|
||||||
n += 1 + l + runtime.Sov(uint64(l))
|
|
||||||
}
|
|
||||||
if x.unknownFields != nil {
|
|
||||||
n += len(x.unknownFields)
|
|
||||||
}
|
|
||||||
return protoiface.SizeOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Size: n,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) {
|
|
||||||
x := input.Message.Interface().(*DWN)
|
|
||||||
if x == nil {
|
|
||||||
return protoiface.MarshalOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Buf: input.Buf,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
options := runtime.MarshalInputToOptions(input)
|
|
||||||
_ = options
|
|
||||||
size := options.Size(x)
|
|
||||||
dAtA := make([]byte, size)
|
|
||||||
i := len(dAtA)
|
|
||||||
_ = i
|
|
||||||
var l int
|
|
||||||
_ = l
|
|
||||||
if x.unknownFields != nil {
|
|
||||||
i -= len(x.unknownFields)
|
|
||||||
copy(dAtA[i:], x.unknownFields)
|
|
||||||
}
|
|
||||||
if len(x.Resolver) > 0 {
|
|
||||||
i -= len(x.Resolver)
|
|
||||||
copy(dAtA[i:], x.Resolver)
|
|
||||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Resolver)))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x22
|
|
||||||
}
|
|
||||||
if len(x.Cid) > 0 {
|
|
||||||
i -= len(x.Cid)
|
|
||||||
copy(dAtA[i:], x.Cid)
|
|
||||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Cid)))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x1a
|
|
||||||
}
|
|
||||||
if len(x.Alias) > 0 {
|
|
||||||
i -= len(x.Alias)
|
|
||||||
copy(dAtA[i:], x.Alias)
|
|
||||||
i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Alias)))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x12
|
|
||||||
}
|
|
||||||
if x.Id != 0 {
|
|
||||||
i = runtime.EncodeVarint(dAtA, i, uint64(x.Id))
|
|
||||||
i--
|
|
||||||
dAtA[i] = 0x8
|
|
||||||
}
|
|
||||||
if input.Buf != nil {
|
|
||||||
input.Buf = append(input.Buf, dAtA...)
|
|
||||||
} else {
|
|
||||||
input.Buf = dAtA
|
|
||||||
}
|
|
||||||
return protoiface.MarshalOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Buf: input.Buf,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) {
|
|
||||||
x := input.Message.Interface().(*DWN)
|
|
||||||
if x == nil {
|
|
||||||
return protoiface.UnmarshalOutput{
|
|
||||||
NoUnkeyedLiterals: input.NoUnkeyedLiterals,
|
|
||||||
Flags: input.Flags,
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
options := runtime.UnmarshalInputToOptions(input)
|
|
||||||
_ = options
|
|
||||||
dAtA := input.Buf
|
|
||||||
l := len(dAtA)
|
|
||||||
iNdEx := 0
|
|
||||||
for iNdEx < l {
|
|
||||||
preIndex := iNdEx
|
|
||||||
var wire uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
wire |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fieldNum := int32(wire >> 3)
|
|
||||||
wireType := int(wire & 0x7)
|
|
||||||
if wireType == 4 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: DWN: wiretype end group for non-group")
|
|
||||||
}
|
|
||||||
if fieldNum <= 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: DWN: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
||||||
}
|
|
||||||
switch fieldNum {
|
|
||||||
case 1:
|
|
||||||
if wireType != 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
|
|
||||||
}
|
|
||||||
x.Id = 0
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
x.Id |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
case 2:
|
|
||||||
if wireType != 2 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Alias", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
stringLen |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intStringLen := int(stringLen)
|
|
||||||
if intStringLen < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
if postIndex > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
x.Alias = string(dAtA[iNdEx:postIndex])
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 3:
|
|
||||||
if wireType != 2 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
stringLen |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intStringLen := int(stringLen)
|
|
||||||
if intStringLen < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
if postIndex > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
x.Cid = string(dAtA[iNdEx:postIndex])
|
|
||||||
iNdEx = postIndex
|
|
||||||
case 4:
|
|
||||||
if wireType != 2 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Resolver", wireType)
|
|
||||||
}
|
|
||||||
var stringLen uint64
|
|
||||||
for shift := uint(0); ; shift += 7 {
|
|
||||||
if shift >= 64 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow
|
|
||||||
}
|
|
||||||
if iNdEx >= l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
b := dAtA[iNdEx]
|
|
||||||
iNdEx++
|
|
||||||
stringLen |= uint64(b&0x7F) << shift
|
|
||||||
if b < 0x80 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
intStringLen := int(stringLen)
|
|
||||||
if intStringLen < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
postIndex := iNdEx + intStringLen
|
|
||||||
if postIndex < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
if postIndex > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
x.Resolver = string(dAtA[iNdEx:postIndex])
|
|
||||||
iNdEx = postIndex
|
|
||||||
default:
|
|
||||||
iNdEx = preIndex
|
|
||||||
skippy, err := runtime.Skip(dAtA[iNdEx:])
|
|
||||||
if err != nil {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err
|
|
||||||
}
|
|
||||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength
|
|
||||||
}
|
|
||||||
if (iNdEx + skippy) > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
if !options.DiscardUnknown {
|
|
||||||
x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)
|
|
||||||
}
|
|
||||||
iNdEx += skippy
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if iNdEx > l {
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil
|
|
||||||
}
|
|
||||||
return &protoiface.Methods{
|
|
||||||
NoUnkeyedLiterals: struct{}{},
|
|
||||||
Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown,
|
|
||||||
Size: size,
|
|
||||||
Marshal: marshal,
|
|
||||||
Unmarshal: unmarshal,
|
|
||||||
Merge: nil,
|
|
||||||
CheckInitialized: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// protoc-gen-go v1.27.0
|
|
||||||
// protoc (unknown)
|
|
||||||
// source: vault/v1/state.proto
|
|
||||||
|
|
||||||
const (
|
|
||||||
// Verify that this generated code is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
||||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
||||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
||||||
)
|
|
||||||
|
|
||||||
type DWN struct {
|
|
||||||
state protoimpl.MessageState
|
|
||||||
sizeCache protoimpl.SizeCache
|
|
||||||
unknownFields protoimpl.UnknownFields
|
|
||||||
|
|
||||||
Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
|
||||||
Alias string `protobuf:"bytes,2,opt,name=alias,proto3" json:"alias,omitempty"`
|
|
||||||
Cid string `protobuf:"bytes,3,opt,name=cid,proto3" json:"cid,omitempty"`
|
|
||||||
Resolver string `protobuf:"bytes,4,opt,name=resolver,proto3" json:"resolver,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) Reset() {
|
|
||||||
*x = DWN{}
|
|
||||||
if protoimpl.UnsafeEnabled {
|
|
||||||
mi := &file_vault_v1_state_proto_msgTypes[0]
|
|
||||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
||||||
ms.StoreMessageInfo(mi)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) String() string {
|
|
||||||
return protoimpl.X.MessageStringOf(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*DWN) ProtoMessage() {}
|
|
||||||
|
|
||||||
// Deprecated: Use DWN.ProtoReflect.Descriptor instead.
|
|
||||||
func (*DWN) Descriptor() ([]byte, []int) {
|
|
||||||
return file_vault_v1_state_proto_rawDescGZIP(), []int{0}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) GetId() uint64 {
|
|
||||||
if x != nil {
|
|
||||||
return x.Id
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) GetAlias() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Alias
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) GetCid() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Cid
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (x *DWN) GetResolver() string {
|
|
||||||
if x != nil {
|
|
||||||
return x.Resolver
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
var File_vault_v1_state_proto protoreflect.FileDescriptor
|
|
||||||
|
|
||||||
var file_vault_v1_state_proto_rawDesc = []byte{
|
|
||||||
0x0a, 0x14, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2f, 0x76, 0x31, 0x2f, 0x73, 0x74, 0x61, 0x74, 0x65,
|
|
||||||
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x08, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31,
|
|
||||||
0x1a, 0x17, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x6f, 0x72, 0x6d, 0x2f, 0x76, 0x31, 0x2f,
|
|
||||||
0x6f, 0x72, 0x6d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x83, 0x01, 0x0a, 0x03, 0x44, 0x57,
|
|
||||||
0x4e, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x02, 0x69,
|
|
||||||
0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
|
||||||
0x52, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x03,
|
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x63, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x72, 0x65, 0x73,
|
|
||||||
0x6f, 0x6c, 0x76, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x65, 0x73,
|
|
||||||
0x6f, 0x6c, 0x76, 0x65, 0x72, 0x3a, 0x28, 0xf2, 0x9e, 0xd3, 0x8e, 0x03, 0x22, 0x0a, 0x06, 0x0a,
|
|
||||||
0x02, 0x69, 0x64, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x05, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x10, 0x01,
|
|
||||||
0x18, 0x01, 0x12, 0x09, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x10, 0x02, 0x18, 0x01, 0x18, 0x01, 0x42,
|
|
||||||
0x88, 0x01, 0x0a, 0x0c, 0x63, 0x6f, 0x6d, 0x2e, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x76, 0x31,
|
|
||||||
0x42, 0x0a, 0x53, 0x74, 0x61, 0x74, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x2b,
|
|
||||||
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6f, 0x6e, 0x73, 0x6f, 0x6e,
|
|
||||||
0x72, 0x2f, 0x73, 0x6f, 0x6e, 0x72, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x61, 0x75, 0x6c, 0x74,
|
|
||||||
0x2f, 0x76, 0x31, 0x3b, 0x76, 0x61, 0x75, 0x6c, 0x74, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x56, 0x58,
|
|
||||||
0x58, 0xaa, 0x02, 0x08, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x2e, 0x56, 0x31, 0xca, 0x02, 0x08, 0x56,
|
|
||||||
0x61, 0x75, 0x6c, 0x74, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x14, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x5c,
|
|
||||||
0x56, 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02,
|
|
||||||
0x09, 0x56, 0x61, 0x75, 0x6c, 0x74, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
|
||||||
0x6f, 0x33,
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
file_vault_v1_state_proto_rawDescOnce sync.Once
|
|
||||||
file_vault_v1_state_proto_rawDescData = file_vault_v1_state_proto_rawDesc
|
|
||||||
)
|
|
||||||
|
|
||||||
func file_vault_v1_state_proto_rawDescGZIP() []byte {
|
|
||||||
file_vault_v1_state_proto_rawDescOnce.Do(func() {
|
|
||||||
file_vault_v1_state_proto_rawDescData = protoimpl.X.CompressGZIP(file_vault_v1_state_proto_rawDescData)
|
|
||||||
})
|
|
||||||
return file_vault_v1_state_proto_rawDescData
|
|
||||||
}
|
|
||||||
|
|
||||||
var file_vault_v1_state_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
|
||||||
var file_vault_v1_state_proto_goTypes = []interface{}{
|
|
||||||
(*DWN)(nil), // 0: vault.v1.DWN
|
|
||||||
}
|
|
||||||
var file_vault_v1_state_proto_depIdxs = []int32{
|
|
||||||
0, // [0:0] is the sub-list for method output_type
|
|
||||||
0, // [0:0] is the sub-list for method input_type
|
|
||||||
0, // [0:0] is the sub-list for extension type_name
|
|
||||||
0, // [0:0] is the sub-list for extension extendee
|
|
||||||
0, // [0:0] is the sub-list for field type_name
|
|
||||||
}
|
|
||||||
|
|
||||||
func init() { file_vault_v1_state_proto_init() }
|
|
||||||
func file_vault_v1_state_proto_init() {
|
|
||||||
if File_vault_v1_state_proto != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !protoimpl.UnsafeEnabled {
|
|
||||||
file_vault_v1_state_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
|
||||||
switch v := v.(*DWN); i {
|
|
||||||
case 0:
|
|
||||||
return &v.state
|
|
||||||
case 1:
|
|
||||||
return &v.sizeCache
|
|
||||||
case 2:
|
|
||||||
return &v.unknownFields
|
|
||||||
default:
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
type x struct{}
|
|
||||||
out := protoimpl.TypeBuilder{
|
|
||||||
File: protoimpl.DescBuilder{
|
|
||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
||||||
RawDescriptor: file_vault_v1_state_proto_rawDesc,
|
|
||||||
NumEnums: 0,
|
|
||||||
NumMessages: 1,
|
|
||||||
NumExtensions: 0,
|
|
||||||
NumServices: 0,
|
|
||||||
},
|
|
||||||
GoTypes: file_vault_v1_state_proto_goTypes,
|
|
||||||
DependencyIndexes: file_vault_v1_state_proto_depIdxs,
|
|
||||||
MessageInfos: file_vault_v1_state_proto_msgTypes,
|
|
||||||
}.Build()
|
|
||||||
File_vault_v1_state_proto = out.File
|
|
||||||
file_vault_v1_state_proto_rawDesc = nil
|
|
||||||
file_vault_v1_state_proto_goTypes = nil
|
|
||||||
file_vault_v1_state_proto_depIdxs = nil
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,131 +0,0 @@
|
|||||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
||||||
// versions:
|
|
||||||
// - protoc-gen-go-grpc v1.5.1
|
|
||||||
// - protoc (unknown)
|
|
||||||
// source: vault/v1/tx.proto
|
|
||||||
|
|
||||||
package vaultv1
|
|
||||||
|
|
||||||
import (
|
|
||||||
context "context"
|
|
||||||
grpc "google.golang.org/grpc"
|
|
||||||
codes "google.golang.org/grpc/codes"
|
|
||||||
status "google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This is a compile-time assertion to ensure that this generated file
|
|
||||||
// is compatible with the grpc package it is being compiled against.
|
|
||||||
// Requires gRPC-Go v1.64.0 or later.
|
|
||||||
const _ = grpc.SupportPackageIsVersion9
|
|
||||||
|
|
||||||
const (
|
|
||||||
Msg_UpdateParams_FullMethodName = "/vault.v1.Msg/UpdateParams"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MsgClient is the client API for Msg service.
|
|
||||||
//
|
|
||||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
||||||
//
|
|
||||||
// Msg defines the Msg service.
|
|
||||||
type MsgClient interface {
|
|
||||||
// UpdateParams defines a governance operation for updating the parameters.
|
|
||||||
//
|
|
||||||
// Since: cosmos-sdk 0.47
|
|
||||||
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
|
|
||||||
}
|
|
||||||
|
|
||||||
type msgClient struct {
|
|
||||||
cc grpc.ClientConnInterface
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewMsgClient(cc grpc.ClientConnInterface) MsgClient {
|
|
||||||
return &msgClient{cc}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
|
|
||||||
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
||||||
out := new(MsgUpdateParamsResponse)
|
|
||||||
err := c.cc.Invoke(ctx, Msg_UpdateParams_FullMethodName, in, out, cOpts...)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MsgServer is the server API for Msg service.
|
|
||||||
// All implementations must embed UnimplementedMsgServer
|
|
||||||
// for forward compatibility.
|
|
||||||
//
|
|
||||||
// Msg defines the Msg service.
|
|
||||||
type MsgServer interface {
|
|
||||||
// UpdateParams defines a governance operation for updating the parameters.
|
|
||||||
//
|
|
||||||
// Since: cosmos-sdk 0.47
|
|
||||||
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
|
|
||||||
mustEmbedUnimplementedMsgServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnimplementedMsgServer must be embedded to have
|
|
||||||
// forward compatible implementations.
|
|
||||||
//
|
|
||||||
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
||||||
// pointer dereference when methods are called.
|
|
||||||
type UnimplementedMsgServer struct{}
|
|
||||||
|
|
||||||
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
|
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
|
|
||||||
}
|
|
||||||
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
|
|
||||||
func (UnimplementedMsgServer) testEmbeddedByValue() {}
|
|
||||||
|
|
||||||
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
|
|
||||||
// Use of this interface is not recommended, as added methods to MsgServer will
|
|
||||||
// result in compilation errors.
|
|
||||||
type UnsafeMsgServer interface {
|
|
||||||
mustEmbedUnimplementedMsgServer()
|
|
||||||
}
|
|
||||||
|
|
||||||
func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) {
|
|
||||||
// If the following call pancis, it indicates UnimplementedMsgServer was
|
|
||||||
// embedded by pointer and is nil. This will cause panics if an
|
|
||||||
// unimplemented method is ever invoked, so we test this at initialization
|
|
||||||
// time to prevent it from happening at runtime later due to I/O.
|
|
||||||
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
||||||
t.testEmbeddedByValue()
|
|
||||||
}
|
|
||||||
s.RegisterService(&Msg_ServiceDesc, srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
||||||
in := new(MsgUpdateParams)
|
|
||||||
if err := dec(in); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if interceptor == nil {
|
|
||||||
return srv.(MsgServer).UpdateParams(ctx, in)
|
|
||||||
}
|
|
||||||
info := &grpc.UnaryServerInfo{
|
|
||||||
Server: srv,
|
|
||||||
FullMethod: Msg_UpdateParams_FullMethodName,
|
|
||||||
}
|
|
||||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
||||||
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
|
|
||||||
}
|
|
||||||
return interceptor(ctx, in, info, handler)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
|
|
||||||
// It's only intended for direct use with grpc.RegisterService,
|
|
||||||
// and not to be introspected or modified (even as a copy)
|
|
||||||
var Msg_ServiceDesc = grpc.ServiceDesc{
|
|
||||||
ServiceName: "vault.v1.Msg",
|
|
||||||
HandlerType: (*MsgServer)(nil),
|
|
||||||
Methods: []grpc.MethodDesc{
|
|
||||||
{
|
|
||||||
MethodName: "UpdateParams",
|
|
||||||
Handler: _Msg_UpdateParams_Handler,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Streams: []grpc.StreamDesc{},
|
|
||||||
Metadata: "vault/v1/tx.proto",
|
|
||||||
}
|
|
||||||
+51
-61
@@ -134,6 +134,15 @@ import (
|
|||||||
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
|
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
|
||||||
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
|
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
|
||||||
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
|
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
|
||||||
|
did "github.com/onsonr/sonr/x/did"
|
||||||
|
didkeeper "github.com/onsonr/sonr/x/did/keeper"
|
||||||
|
didtypes "github.com/onsonr/sonr/x/did/types"
|
||||||
|
dwn "github.com/onsonr/sonr/x/dwn"
|
||||||
|
dwnkeeper "github.com/onsonr/sonr/x/dwn/keeper"
|
||||||
|
dwntypes "github.com/onsonr/sonr/x/dwn/types"
|
||||||
|
svc "github.com/onsonr/sonr/x/svc"
|
||||||
|
svckeeper "github.com/onsonr/sonr/x/svc/keeper"
|
||||||
|
svctypes "github.com/onsonr/sonr/x/svc/types"
|
||||||
"github.com/spf13/cast"
|
"github.com/spf13/cast"
|
||||||
globalfee "github.com/strangelove-ventures/globalfee/x/globalfee"
|
globalfee "github.com/strangelove-ventures/globalfee/x/globalfee"
|
||||||
globalfeekeeper "github.com/strangelove-ventures/globalfee/x/globalfee/keeper"
|
globalfeekeeper "github.com/strangelove-ventures/globalfee/x/globalfee/keeper"
|
||||||
@@ -144,19 +153,6 @@ import (
|
|||||||
tokenfactory "github.com/strangelove-ventures/tokenfactory/x/tokenfactory"
|
tokenfactory "github.com/strangelove-ventures/tokenfactory/x/tokenfactory"
|
||||||
tokenfactorykeeper "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/keeper"
|
tokenfactorykeeper "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/keeper"
|
||||||
tokenfactorytypes "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/types"
|
tokenfactorytypes "github.com/strangelove-ventures/tokenfactory/x/tokenfactory/types"
|
||||||
|
|
||||||
did "github.com/onsonr/sonr/x/did"
|
|
||||||
didkeeper "github.com/onsonr/sonr/x/did/keeper"
|
|
||||||
didtypes "github.com/onsonr/sonr/x/did/types"
|
|
||||||
macaroon "github.com/onsonr/sonr/x/macaroon"
|
|
||||||
macaroonkeeper "github.com/onsonr/sonr/x/macaroon/keeper"
|
|
||||||
macaroontypes "github.com/onsonr/sonr/x/macaroon/types"
|
|
||||||
service "github.com/onsonr/sonr/x/service"
|
|
||||||
servicekeeper "github.com/onsonr/sonr/x/service/keeper"
|
|
||||||
servicetypes "github.com/onsonr/sonr/x/service/types"
|
|
||||||
vault "github.com/onsonr/sonr/x/vault"
|
|
||||||
vaultkeeper "github.com/onsonr/sonr/x/vault/keeper"
|
|
||||||
vaulttypes "github.com/onsonr/sonr/x/vault/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const appName = "sonr"
|
const appName = "sonr"
|
||||||
@@ -235,9 +231,8 @@ type SonrApp struct {
|
|||||||
CrisisKeeper *crisiskeeper.Keeper
|
CrisisKeeper *crisiskeeper.Keeper
|
||||||
UpgradeKeeper *upgradekeeper.Keeper
|
UpgradeKeeper *upgradekeeper.Keeper
|
||||||
legacyAmino *codec.LegacyAmino
|
legacyAmino *codec.LegacyAmino
|
||||||
VaultKeeper vaultkeeper.Keeper
|
DwnKeeper dwnkeeper.Keeper
|
||||||
MacaroonKeeper macaroonkeeper.Keeper
|
SvcKeeper svckeeper.Keeper
|
||||||
ServiceKeeper servicekeeper.Keeper
|
|
||||||
sm *module.SimulationManager
|
sm *module.SimulationManager
|
||||||
BasicModuleManager module.BasicManager
|
BasicModuleManager module.BasicManager
|
||||||
ModuleManager *module.Manager
|
ModuleManager *module.Manager
|
||||||
@@ -370,9 +365,8 @@ func NewChainApp(
|
|||||||
globalfeetypes.StoreKey,
|
globalfeetypes.StoreKey,
|
||||||
packetforwardtypes.StoreKey,
|
packetforwardtypes.StoreKey,
|
||||||
didtypes.StoreKey,
|
didtypes.StoreKey,
|
||||||
vaulttypes.StoreKey,
|
dwntypes.StoreKey,
|
||||||
macaroontypes.StoreKey,
|
svctypes.StoreKey,
|
||||||
servicetypes.StoreKey,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
|
tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey)
|
||||||
@@ -632,40 +626,43 @@ func NewChainApp(
|
|||||||
app.StakingKeeper,
|
app.StakingKeeper,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create the macaroon Keeper
|
// Create the svc Keeper
|
||||||
app.MacaroonKeeper = macaroonkeeper.NewKeeper(
|
app.SvcKeeper = svckeeper.NewKeeper(
|
||||||
appCodec,
|
appCodec,
|
||||||
sdkruntime.NewKVStoreService(keys[macaroontypes.StoreKey]),
|
sdkruntime.NewKVStoreService(keys[svctypes.StoreKey]),
|
||||||
logger,
|
logger,
|
||||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||||
app.AccountKeeper,
|
|
||||||
app.DidKeeper,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Create the vault Keeper
|
// Create the dwn Keeper
|
||||||
app.VaultKeeper = vaultkeeper.NewKeeper(
|
app.DwnKeeper = dwnkeeper.NewKeeper(
|
||||||
appCodec,
|
appCodec,
|
||||||
sdkruntime.NewKVStoreService(keys[vaulttypes.StoreKey]),
|
sdkruntime.NewKVStoreService(keys[dwntypes.StoreKey]),
|
||||||
logger,
|
logger,
|
||||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||||
app.AccountKeeper,
|
|
||||||
app.DidKeeper,
|
|
||||||
app.MacaroonKeeper,
|
|
||||||
)
|
)
|
||||||
|
// // Create the vault Keeper
|
||||||
// Create the service Keeper
|
// app.VaultKeeper = vaultkeeper.NewKeeper(
|
||||||
app.ServiceKeeper = servicekeeper.NewKeeper(
|
// appCodec,
|
||||||
appCodec,
|
// sdkruntime.NewKVStoreService(keys[vaulttypes.StoreKey]),
|
||||||
sdkruntime.NewKVStoreService(keys[servicetypes.StoreKey]),
|
// logger,
|
||||||
logger,
|
// authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||||
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
// app.AccountKeeper,
|
||||||
app.DidKeeper,
|
// app.DidKeeper,
|
||||||
app.GroupKeeper,
|
// )
|
||||||
app.MacaroonKeeper,
|
//
|
||||||
app.NFTKeeper,
|
// // Create the service Keeper
|
||||||
app.VaultKeeper,
|
// app.ServiceKeeper = servicekeeper.NewKeeper(
|
||||||
)
|
// appCodec,
|
||||||
|
// sdkruntime.NewKVStoreService(keys[servicetypes.StoreKey]),
|
||||||
|
// logger,
|
||||||
|
// authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
||||||
|
// app.DidKeeper,
|
||||||
|
// app.GroupKeeper,
|
||||||
|
// app.NFTKeeper,
|
||||||
|
// app.VaultKeeper,
|
||||||
|
// )
|
||||||
|
//
|
||||||
// Create the globalfee keeper
|
// Create the globalfee keeper
|
||||||
app.GlobalFeeKeeper = globalfeekeeper.NewKeeper(
|
app.GlobalFeeKeeper = globalfeekeeper.NewKeeper(
|
||||||
appCodec,
|
appCodec,
|
||||||
@@ -923,11 +920,8 @@ func NewChainApp(
|
|||||||
),
|
),
|
||||||
|
|
||||||
did.NewAppModule(appCodec, app.DidKeeper, app.NFTKeeper),
|
did.NewAppModule(appCodec, app.DidKeeper, app.NFTKeeper),
|
||||||
|
dwn.NewAppModule(appCodec, app.DwnKeeper),
|
||||||
macaroon.NewAppModule(appCodec, app.MacaroonKeeper, app.DidKeeper),
|
svc.NewAppModule(appCodec, app.SvcKeeper),
|
||||||
vault.NewAppModule(appCodec, app.VaultKeeper, app.DidKeeper),
|
|
||||||
|
|
||||||
service.NewAppModule(appCodec, app.ServiceKeeper, app.DidKeeper, app.MacaroonKeeper),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
|
// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
|
||||||
@@ -976,9 +970,8 @@ func NewChainApp(
|
|||||||
tokenfactorytypes.ModuleName,
|
tokenfactorytypes.ModuleName,
|
||||||
packetforwardtypes.ModuleName,
|
packetforwardtypes.ModuleName,
|
||||||
didtypes.ModuleName,
|
didtypes.ModuleName,
|
||||||
vaulttypes.ModuleName,
|
dwntypes.ModuleName,
|
||||||
macaroontypes.ModuleName,
|
svctypes.ModuleName,
|
||||||
servicetypes.ModuleName,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
app.ModuleManager.SetOrderEndBlockers(
|
app.ModuleManager.SetOrderEndBlockers(
|
||||||
@@ -998,9 +991,8 @@ func NewChainApp(
|
|||||||
tokenfactorytypes.ModuleName,
|
tokenfactorytypes.ModuleName,
|
||||||
packetforwardtypes.ModuleName,
|
packetforwardtypes.ModuleName,
|
||||||
didtypes.ModuleName,
|
didtypes.ModuleName,
|
||||||
vaulttypes.ModuleName,
|
dwntypes.ModuleName,
|
||||||
macaroontypes.ModuleName,
|
svctypes.ModuleName,
|
||||||
servicetypes.ModuleName,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: The genutils module must occur after staking so that pools are
|
// NOTE: The genutils module must occur after staking so that pools are
|
||||||
@@ -1029,9 +1021,8 @@ func NewChainApp(
|
|||||||
globalfeetypes.ModuleName,
|
globalfeetypes.ModuleName,
|
||||||
packetforwardtypes.ModuleName,
|
packetforwardtypes.ModuleName,
|
||||||
didtypes.ModuleName,
|
didtypes.ModuleName,
|
||||||
vaulttypes.ModuleName,
|
dwntypes.ModuleName,
|
||||||
macaroontypes.ModuleName,
|
svctypes.ModuleName,
|
||||||
servicetypes.ModuleName,
|
|
||||||
}
|
}
|
||||||
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
|
app.ModuleManager.SetOrderInitGenesis(genesisModuleOrder...)
|
||||||
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
|
app.ModuleManager.SetOrderExportGenesis(genesisModuleOrder...)
|
||||||
@@ -1490,9 +1481,8 @@ func initParamsKeeper(
|
|||||||
paramsKeeper.Subspace(packetforwardtypes.ModuleName).
|
paramsKeeper.Subspace(packetforwardtypes.ModuleName).
|
||||||
WithKeyTable(packetforwardtypes.ParamKeyTable())
|
WithKeyTable(packetforwardtypes.ParamKeyTable())
|
||||||
paramsKeeper.Subspace(didtypes.ModuleName)
|
paramsKeeper.Subspace(didtypes.ModuleName)
|
||||||
paramsKeeper.Subspace(vaulttypes.ModuleName)
|
paramsKeeper.Subspace(dwntypes.ModuleName)
|
||||||
paramsKeeper.Subspace(macaroontypes.ModuleName)
|
paramsKeeper.Subspace(svctypes.ModuleName)
|
||||||
paramsKeeper.Subspace(servicetypes.ModuleName)
|
|
||||||
|
|
||||||
return paramsKeeper
|
return paramsKeeper
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,165 +0,0 @@
|
|||||||
package dexmodel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/charmbracelet/bubbles/table"
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
|
||||||
"github.com/charmbracelet/lipgloss"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
subtle = lipgloss.AdaptiveColor{Light: "#D9DCCF", Dark: "#383838"}
|
|
||||||
highlight = lipgloss.AdaptiveColor{Light: "#874BFD", Dark: "#7D56F4"}
|
|
||||||
special = lipgloss.AdaptiveColor{Light: "#43BF6D", Dark: "#73F59F"}
|
|
||||||
|
|
||||||
titleStyle = lipgloss.NewStyle().
|
|
||||||
MarginLeft(1).
|
|
||||||
MarginRight(5).
|
|
||||||
Padding(0, 1).
|
|
||||||
Italic(true).
|
|
||||||
Foreground(lipgloss.Color("#FFF7DB")).
|
|
||||||
SetString("Cosmos Block Explorer")
|
|
||||||
|
|
||||||
infoStyle = lipgloss.NewStyle().
|
|
||||||
BorderStyle(lipgloss.NormalBorder()).
|
|
||||||
BorderTop(true).
|
|
||||||
BorderForeground(subtle)
|
|
||||||
)
|
|
||||||
|
|
||||||
type model struct {
|
|
||||||
blocks []string
|
|
||||||
transactionTable table.Model
|
|
||||||
stats map[string]string
|
|
||||||
width int
|
|
||||||
height int
|
|
||||||
}
|
|
||||||
|
|
||||||
func initialModel() model {
|
|
||||||
columns := []table.Column{
|
|
||||||
{Title: "Hash", Width: 10},
|
|
||||||
{Title: "Type", Width: 15},
|
|
||||||
{Title: "Height", Width: 10},
|
|
||||||
{Title: "Time", Width: 20},
|
|
||||||
}
|
|
||||||
|
|
||||||
rows := []table.Row{
|
|
||||||
{"abc123", "Transfer", "1000", time.Now().Format(time.RFC3339)},
|
|
||||||
{"def456", "Delegate", "999", time.Now().Add(-1 * time.Minute).Format(time.RFC3339)},
|
|
||||||
{"ghi789", "Vote", "998", time.Now().Add(-2 * time.Minute).Format(time.RFC3339)},
|
|
||||||
}
|
|
||||||
|
|
||||||
t := table.New(
|
|
||||||
table.WithColumns(columns),
|
|
||||||
table.WithRows(rows),
|
|
||||||
table.WithFocused(true),
|
|
||||||
table.WithHeight(7),
|
|
||||||
)
|
|
||||||
|
|
||||||
s := table.DefaultStyles()
|
|
||||||
s.Header = s.Header.
|
|
||||||
BorderStyle(lipgloss.NormalBorder()).
|
|
||||||
BorderForeground(lipgloss.Color("240")).
|
|
||||||
BorderBottom(true).
|
|
||||||
Bold(false)
|
|
||||||
s.Selected = s.Selected.
|
|
||||||
Foreground(lipgloss.Color("229")).
|
|
||||||
Background(lipgloss.Color("57")).
|
|
||||||
Bold(false)
|
|
||||||
t.SetStyles(s)
|
|
||||||
|
|
||||||
return model{
|
|
||||||
blocks: []string{"Block 1", "Block 2", "Block 3"},
|
|
||||||
transactionTable: t,
|
|
||||||
stats: map[string]string{
|
|
||||||
"Latest Block": "1000",
|
|
||||||
"Validators": "100",
|
|
||||||
"Bonded Tokens": "1,000,000",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m model) Init() tea.Cmd {
|
|
||||||
return tick
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
||||||
var cmd tea.Cmd
|
|
||||||
switch msg := msg.(type) {
|
|
||||||
case tea.KeyMsg:
|
|
||||||
switch msg.String() {
|
|
||||||
case "q", "ctrl+c":
|
|
||||||
return m, tea.Quit
|
|
||||||
case "enter":
|
|
||||||
return m, tea.Batch(
|
|
||||||
tea.Printf("Selected transaction: %s", m.transactionTable.SelectedRow()[0]),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
case tea.WindowSizeMsg:
|
|
||||||
m.height = msg.Height
|
|
||||||
m.width = msg.Width
|
|
||||||
case tickMsg:
|
|
||||||
// Update data here
|
|
||||||
m.blocks = append([]string{"New Block"}, m.blocks...)
|
|
||||||
if len(m.blocks) > 5 {
|
|
||||||
m.blocks = m.blocks[:5]
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a new transaction to the table
|
|
||||||
newRow := table.Row{
|
|
||||||
fmt.Sprintf("tx%d", time.Now().Unix()),
|
|
||||||
"NewTxType",
|
|
||||||
fmt.Sprintf("%d", 1000+len(m.transactionTable.Rows())),
|
|
||||||
time.Now().Format(time.RFC3339),
|
|
||||||
}
|
|
||||||
m.transactionTable.SetRows(append([]table.Row{newRow}, m.transactionTable.Rows()...))
|
|
||||||
if len(m.transactionTable.Rows()) > 10 {
|
|
||||||
m.transactionTable.SetRows(m.transactionTable.Rows()[:10])
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, tick
|
|
||||||
}
|
|
||||||
m.transactionTable, cmd = m.transactionTable.Update(msg)
|
|
||||||
return m, cmd
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m model) View() string {
|
|
||||||
s := titleStyle.Render("Cosmos Block Explorer")
|
|
||||||
s += "\n\n"
|
|
||||||
|
|
||||||
// Blocks
|
|
||||||
s += lipgloss.NewStyle().Bold(true).Render("Recent Blocks") + "\n"
|
|
||||||
for _, block := range m.blocks {
|
|
||||||
s += "• " + block + "\n"
|
|
||||||
}
|
|
||||||
s += "\n"
|
|
||||||
|
|
||||||
// Transactions
|
|
||||||
s += lipgloss.NewStyle().Bold(true).Render("Recent Transactions") + "\n"
|
|
||||||
s += m.transactionTable.View() + "\n\n"
|
|
||||||
|
|
||||||
// Stats
|
|
||||||
s += lipgloss.NewStyle().Bold(true).Render("Network Statistics") + "\n"
|
|
||||||
for key, value := range m.stats {
|
|
||||||
s += fmt.Sprintf("%s: %s\n", key, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
type tickMsg time.Time
|
|
||||||
|
|
||||||
func tick() tea.Msg {
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
return tickMsg{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func RunExplorerTUI(cmd *cobra.Command, args []string) error {
|
|
||||||
p := tea.NewProgram(initialModel(), tea.WithAltScreen())
|
|
||||||
if _, err := p.Run(); err != nil {
|
|
||||||
return fmt.Errorf("error running explorer: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
||||||
"github.com/onsonr/sonr/app/cli/dexmodel"
|
|
||||||
"github.com/onsonr/sonr/app/cli/txmodel"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
func NewBuildTxnTUICmd() *cobra.Command {
|
|
||||||
return &cobra.Command{
|
|
||||||
Use: "dash",
|
|
||||||
Short: "TUI for managing the local Sonr validator node",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
txBody, err := txmodel.RunBuildTxnTUI()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaceRegistry := codectypes.NewInterfaceRegistry()
|
|
||||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
|
||||||
jsonBytes, err := marshaler.MarshalJSON(txBody)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to marshal tx body: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println("Generated Protobuf Message (JSON format):")
|
|
||||||
fmt.Println(string(jsonBytes))
|
|
||||||
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewExplorerTUICmd() *cobra.Command {
|
|
||||||
return &cobra.Command{
|
|
||||||
Use: "cosmos-explorer",
|
|
||||||
Short: "A terminal-based Cosmos blockchain explorer",
|
|
||||||
RunE: dexmodel.RunExplorerTUI,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,322 +0,0 @@
|
|||||||
package txmodel
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
tea "github.com/charmbracelet/bubbletea"
|
|
||||||
"github.com/charmbracelet/huh"
|
|
||||||
"github.com/charmbracelet/lipgloss"
|
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
|
||||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
|
||||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
const maxWidth = 100
|
|
||||||
|
|
||||||
var (
|
|
||||||
red = lipgloss.AdaptiveColor{Light: "#FE5F86", Dark: "#FE5F86"}
|
|
||||||
indigo = lipgloss.AdaptiveColor{Light: "#5A56E0", Dark: "#7571F9"}
|
|
||||||
green = lipgloss.AdaptiveColor{Light: "#02BA84", Dark: "#02BF87"}
|
|
||||||
)
|
|
||||||
|
|
||||||
type Styles struct {
|
|
||||||
Base,
|
|
||||||
HeaderText,
|
|
||||||
Status,
|
|
||||||
StatusHeader,
|
|
||||||
Highlight,
|
|
||||||
ErrorHeaderText,
|
|
||||||
Help lipgloss.Style
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewStyles(lg *lipgloss.Renderer) *Styles {
|
|
||||||
s := Styles{}
|
|
||||||
s.Base = lg.NewStyle().
|
|
||||||
Padding(1, 2, 0, 1)
|
|
||||||
s.HeaderText = lg.NewStyle().
|
|
||||||
Foreground(indigo).
|
|
||||||
Bold(true).
|
|
||||||
Padding(0, 1, 0, 1)
|
|
||||||
s.Status = lg.NewStyle().
|
|
||||||
Border(lipgloss.RoundedBorder()).
|
|
||||||
BorderForeground(indigo).
|
|
||||||
PaddingLeft(1).
|
|
||||||
MarginTop(1)
|
|
||||||
s.StatusHeader = lg.NewStyle().
|
|
||||||
Foreground(green).
|
|
||||||
Bold(true)
|
|
||||||
s.Highlight = lg.NewStyle().
|
|
||||||
Foreground(lipgloss.Color("212"))
|
|
||||||
s.ErrorHeaderText = s.HeaderText.
|
|
||||||
Foreground(red)
|
|
||||||
s.Help = lg.NewStyle().
|
|
||||||
Foreground(lipgloss.Color("240"))
|
|
||||||
return &s
|
|
||||||
}
|
|
||||||
|
|
||||||
type state int
|
|
||||||
|
|
||||||
const (
|
|
||||||
statusNormal state = iota
|
|
||||||
stateDone
|
|
||||||
)
|
|
||||||
|
|
||||||
type Model struct {
|
|
||||||
state state
|
|
||||||
lg *lipgloss.Renderer
|
|
||||||
styles *Styles
|
|
||||||
form *huh.Form
|
|
||||||
width int
|
|
||||||
message *tx.TxBody
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewModel() Model {
|
|
||||||
m := Model{width: maxWidth}
|
|
||||||
m.lg = lipgloss.DefaultRenderer()
|
|
||||||
m.styles = NewStyles(m.lg)
|
|
||||||
|
|
||||||
m.form = huh.NewForm(
|
|
||||||
huh.NewGroup(
|
|
||||||
huh.NewInput().
|
|
||||||
Key("from").
|
|
||||||
Title("From Address").
|
|
||||||
Placeholder("cosmos1...").
|
|
||||||
Validate(func(s string) error {
|
|
||||||
if !strings.HasPrefix(s, "cosmos1") {
|
|
||||||
return fmt.Errorf("invalid address format")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}),
|
|
||||||
|
|
||||||
huh.NewInput().
|
|
||||||
Key("to").
|
|
||||||
Title("To Address").
|
|
||||||
Placeholder("cosmos1...").
|
|
||||||
Validate(func(s string) error {
|
|
||||||
if !strings.HasPrefix(s, "cosmos1") {
|
|
||||||
return fmt.Errorf("invalid address format")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}),
|
|
||||||
|
|
||||||
huh.NewInput().
|
|
||||||
Key("amount").
|
|
||||||
Title("Amount").
|
|
||||||
Placeholder("100").
|
|
||||||
Validate(func(s string) error {
|
|
||||||
if _, err := sdk.ParseCoinNormalized(s + "atom"); err != nil {
|
|
||||||
return fmt.Errorf("invalid coin amount")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}),
|
|
||||||
|
|
||||||
huh.NewSelect[string]().
|
|
||||||
Key("denom").
|
|
||||||
Title("Denom").
|
|
||||||
Options(huh.NewOptions("atom", "osmo", "usnr", "snr")...),
|
|
||||||
|
|
||||||
huh.NewInput().
|
|
||||||
Key("memo").
|
|
||||||
Title("Memo").
|
|
||||||
Placeholder("Optional"),
|
|
||||||
|
|
||||||
huh.NewConfirm().
|
|
||||||
Key("done").
|
|
||||||
Title("Ready to convert?").
|
|
||||||
Validate(func(v bool) error {
|
|
||||||
if !v {
|
|
||||||
return fmt.Errorf("Please confirm when you're ready to convert")
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}).
|
|
||||||
Affirmative("Yes, convert!").
|
|
||||||
Negative("Not yet"),
|
|
||||||
),
|
|
||||||
).
|
|
||||||
WithWidth(60).
|
|
||||||
WithShowHelp(false).
|
|
||||||
WithShowErrors(false)
|
|
||||||
|
|
||||||
return m
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) Init() tea.Cmd {
|
|
||||||
return m.form.Init()
|
|
||||||
}
|
|
||||||
|
|
||||||
func min(x, y int) int {
|
|
||||||
if x > y {
|
|
||||||
return y
|
|
||||||
}
|
|
||||||
return x
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
|
||||||
switch msg := msg.(type) {
|
|
||||||
case tea.WindowSizeMsg:
|
|
||||||
m.width = min(msg.Width, maxWidth) - m.styles.Base.GetHorizontalFrameSize()
|
|
||||||
case tea.KeyMsg:
|
|
||||||
switch msg.String() {
|
|
||||||
case "esc", "ctrl+c", "q":
|
|
||||||
return m, tea.Quit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var cmds []tea.Cmd
|
|
||||||
|
|
||||||
form, cmd := m.form.Update(msg)
|
|
||||||
if f, ok := form.(*huh.Form); ok {
|
|
||||||
m.form = f
|
|
||||||
cmds = append(cmds, cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
if m.form.State == huh.StateCompleted {
|
|
||||||
m.buildMessage()
|
|
||||||
cmds = append(cmds, tea.Quit)
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, tea.Batch(cmds...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) View() string {
|
|
||||||
s := m.styles
|
|
||||||
|
|
||||||
switch m.form.State {
|
|
||||||
case huh.StateCompleted:
|
|
||||||
pklCode := m.generatePkl()
|
|
||||||
messageView := m.getMessageView()
|
|
||||||
var b strings.Builder
|
|
||||||
fmt.Fprintf(&b, "Final Tx:\n\n%s\n\n%s", pklCode, messageView)
|
|
||||||
return s.Status.Margin(0, 1).Padding(1, 2).Width(80).Render(b.String()) + "\n\n"
|
|
||||||
default:
|
|
||||||
var schemaType string
|
|
||||||
if m.form.GetString("schemaType") != "" {
|
|
||||||
schemaType = "Schema Type: " + m.form.GetString("schemaType")
|
|
||||||
}
|
|
||||||
|
|
||||||
v := strings.TrimSuffix(m.form.View(), "\n\n")
|
|
||||||
form := m.lg.NewStyle().Margin(1, 0).Render(v)
|
|
||||||
|
|
||||||
var status string
|
|
||||||
{
|
|
||||||
preview := "(Preview will appear here)"
|
|
||||||
if m.form.GetString("schema") != "" {
|
|
||||||
preview = m.generatePkl()
|
|
||||||
}
|
|
||||||
|
|
||||||
const statusWidth = 40
|
|
||||||
statusMarginLeft := m.width - statusWidth - lipgloss.Width(form) - s.Status.GetMarginRight()
|
|
||||||
status = s.Status.
|
|
||||||
Height(lipgloss.Height(form)).
|
|
||||||
Width(statusWidth).
|
|
||||||
MarginLeft(statusMarginLeft).
|
|
||||||
Render(s.StatusHeader.Render("Pkl Preview") + "\n" +
|
|
||||||
schemaType + "\n\n" +
|
|
||||||
preview)
|
|
||||||
}
|
|
||||||
|
|
||||||
errors := m.form.Errors()
|
|
||||||
header := m.appBoundaryView("Sonr TX Builder")
|
|
||||||
if len(errors) > 0 {
|
|
||||||
header = m.appErrorBoundaryView(m.errorView())
|
|
||||||
}
|
|
||||||
body := lipgloss.JoinHorizontal(lipgloss.Top, form, status)
|
|
||||||
|
|
||||||
footer := m.appBoundaryView(m.form.Help().ShortHelpView(m.form.KeyBinds()))
|
|
||||||
if len(errors) > 0 {
|
|
||||||
footer = m.appErrorBoundaryView("")
|
|
||||||
}
|
|
||||||
|
|
||||||
return s.Base.Render(header + "\n" + body + "\n\n" + footer)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) errorView() string {
|
|
||||||
var s string
|
|
||||||
for _, err := range m.form.Errors() {
|
|
||||||
s += err.Error()
|
|
||||||
}
|
|
||||||
return s
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) appBoundaryView(text string) string {
|
|
||||||
return lipgloss.PlaceHorizontal(
|
|
||||||
m.width,
|
|
||||||
lipgloss.Left,
|
|
||||||
m.styles.HeaderText.Render(text),
|
|
||||||
lipgloss.WithWhitespaceChars("="),
|
|
||||||
lipgloss.WithWhitespaceForeground(indigo),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) appErrorBoundaryView(text string) string {
|
|
||||||
return lipgloss.PlaceHorizontal(
|
|
||||||
m.width,
|
|
||||||
lipgloss.Left,
|
|
||||||
m.styles.ErrorHeaderText.Render(text),
|
|
||||||
lipgloss.WithWhitespaceChars("="),
|
|
||||||
lipgloss.WithWhitespaceForeground(red),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) generatePkl() string {
|
|
||||||
schemaType := m.form.GetString("schemaType")
|
|
||||||
schema := m.form.GetString("schema")
|
|
||||||
|
|
||||||
// This is a placeholder for the actual conversion logic
|
|
||||||
// In a real implementation, you would parse the schema and generate Pkl code
|
|
||||||
return fmt.Sprintf("// Converted from %s\n\nclass ConvertedSchema {\n // TODO: Implement conversion from %s\n // Original schema:\n /*\n%s\n */\n}", schemaType, schemaType, schema)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m *Model) buildMessage() {
|
|
||||||
from := m.form.GetString("from")
|
|
||||||
to := m.form.GetString("to")
|
|
||||||
amount := m.form.GetString("amount")
|
|
||||||
denom := m.form.GetString("denom")
|
|
||||||
memo := m.form.GetString("memo")
|
|
||||||
|
|
||||||
coin, _ := sdk.ParseCoinNormalized(fmt.Sprintf("%s%s", amount, denom))
|
|
||||||
sendMsg := &banktypes.MsgSend{
|
|
||||||
FromAddress: from,
|
|
||||||
ToAddress: to,
|
|
||||||
Amount: sdk.NewCoins(coin),
|
|
||||||
}
|
|
||||||
|
|
||||||
anyMsg, _ := codectypes.NewAnyWithValue(sendMsg)
|
|
||||||
m.message = &tx.TxBody{
|
|
||||||
Messages: []*codectypes.Any{anyMsg},
|
|
||||||
Memo: memo,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (m Model) getMessageView() string {
|
|
||||||
if m.message == nil {
|
|
||||||
return "Current Message: None"
|
|
||||||
}
|
|
||||||
|
|
||||||
interfaceRegistry := codectypes.NewInterfaceRegistry()
|
|
||||||
marshaler := codec.NewProtoCodec(interfaceRegistry)
|
|
||||||
jsonBytes, _ := marshaler.MarshalJSON(m.message)
|
|
||||||
|
|
||||||
return fmt.Sprintf("Current Message:\n%s", string(jsonBytes))
|
|
||||||
}
|
|
||||||
|
|
||||||
func RunBuildTxnTUI() (*tx.TxBody, error) {
|
|
||||||
m := NewModel()
|
|
||||||
p := tea.NewProgram(m)
|
|
||||||
|
|
||||||
finalModel, err := p.Run()
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed to run program: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
finalM, ok := finalModel.(Model)
|
|
||||||
if !ok || finalM.message == nil {
|
|
||||||
return nil, fmt.Errorf("form not completed")
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalM.message, nil
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
version: v1
|
||||||
|
directories:
|
||||||
|
- proto
|
||||||
Binary file not shown.
@@ -0,0 +1,71 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/pkg/common"
|
||||||
|
"github.com/onsonr/sonr/pkg/gateway"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Command line flags
|
||||||
|
var (
|
||||||
|
servePort int // Gateway http entry point (default 3000)
|
||||||
|
chainID string // Current chain ID (default sonr-testnet-1)
|
||||||
|
ipfsGatewayURL string // IPFS gateway URL (default localhost:8080)
|
||||||
|
sonrAPIURL string // Sonr API URL (default localhost:1317)
|
||||||
|
sonrGrpcURL string // Sonr gRPC URL (default localhost:9090)
|
||||||
|
sonrRPCURL string // Sonr RPC URL (default localhost:26657)
|
||||||
|
|
||||||
|
psqlHost string // PostgresSQL Host Flag
|
||||||
|
psqlUser string // PostgresSQL User Flag
|
||||||
|
psqlPass string // PostgresSQL Password Flag
|
||||||
|
psqlDB string // PostgresSQL Database Flag
|
||||||
|
)
|
||||||
|
|
||||||
|
func rootCmd() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "hway",
|
||||||
|
Short: "Sonr DID gateway",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
env, err := loadEnvImplFromArgs(args)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
ipc, err := common.NewIPFS()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
e, err := gateway.New(env, ipc)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if err := e.Start(fmt.Sprintf(":%d", env.GetServePort())); err != http.ErrServerClosed {
|
||||||
|
log.Fatal(err)
|
||||||
|
os.Exit(1)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
cmd.Flags().IntVar(&servePort, "serve-port", 3000, "Port to serve the gateway on")
|
||||||
|
cmd.Flags().StringVar(&chainID, "chain-id", "sonr-testnet-1", "Chain ID")
|
||||||
|
cmd.Flags().StringVar(&ipfsGatewayURL, "ipfs-gateway-url", "localhost:8080", "IPFS gateway URL")
|
||||||
|
cmd.Flags().StringVar(&sonrAPIURL, "sonr-api-url", "localhost:1317", "Sonr API URL")
|
||||||
|
cmd.Flags().StringVar(&sonrGrpcURL, "sonr-grpc-url", "localhost:9090", "Sonr gRPC URL")
|
||||||
|
cmd.Flags().StringVar(&sonrRPCURL, "sonr-rpc-url", "localhost:26657", "Sonr RPC URL")
|
||||||
|
cmd.Flags().StringVar(&psqlHost, "psql-host", "", "PostgresSQL Host")
|
||||||
|
cmd.Flags().StringVar(&psqlUser, "psql-user", "", "PostgresSQL User")
|
||||||
|
cmd.Flags().StringVar(&psqlPass, "psql-pass", "", "PostgresSQL Password")
|
||||||
|
cmd.Flags().StringVar(&psqlDB, "psql-db", "", "PostgresSQL Database")
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func formatPsqlDSN() string {
|
||||||
|
if psqlHost == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("host=%s user=%s password=%s dbname=%s sslmode=disable", psqlHost, psqlUser, psqlPass, psqlDB)
|
||||||
|
}
|
||||||
+30
-11
@@ -1,18 +1,37 @@
|
|||||||
//go:build js && wasm
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/labstack/echo/v4"
|
_ "embed"
|
||||||
"github.com/onsonr/sonr/internal/ctx"
|
"fmt"
|
||||||
"github.com/onsonr/sonr/pkg/workers/routes"
|
"os"
|
||||||
"github.com/syumai/workers"
|
|
||||||
|
config "github.com/onsonr/sonr/internal/config/hway"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// main is the entry point for the application
|
||||||
func main() {
|
func main() {
|
||||||
s := echo.New()
|
cmd := rootCmd()
|
||||||
s.Use(ctx.HighwaySessionMiddleware)
|
if err := cmd.Execute(); err != nil {
|
||||||
routes.RegisterGatewayViews(s)
|
fmt.Println(err)
|
||||||
routes.RegisterGatewayAPI(s)
|
os.Exit(1)
|
||||||
workers.Serve(s)
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func loadEnvImplFromArgs(args []string) (config.Hway, error) {
|
||||||
|
cmd := rootCmd()
|
||||||
|
if err := cmd.ParseFlags(args); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
env := &config.HwayImpl{
|
||||||
|
ServePort: servePort,
|
||||||
|
ChainId: chainID,
|
||||||
|
IpfsGatewayUrl: ipfsGatewayURL,
|
||||||
|
SonrApiUrl: sonrAPIURL,
|
||||||
|
SonrGrpcUrl: sonrGrpcURL,
|
||||||
|
SonrRpcUrl: sonrRPCURL,
|
||||||
|
PsqlDSN: formatPsqlDSN(),
|
||||||
|
}
|
||||||
|
return env, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
name = "sonr-id"
|
|
||||||
main = "./build/worker.mjs"
|
|
||||||
compatibility_date = "2024-10-07"
|
|
||||||
|
|
||||||
routes = [{ pattern = "sonr.id", custom_domain = true }]
|
|
||||||
|
|
||||||
[build]
|
|
||||||
command = "task hway:build"
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
//go:build js && wasm
|
||||||
|
// +build js,wasm
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"syscall/js"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
"github.com/onsonr/sonr/pkg/vault/routes"
|
||||||
|
"github.com/onsonr/sonr/cmd/motr/wasm"
|
||||||
|
"github.com/onsonr/sonr/internal/config/motr"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
env *motr.Environment
|
||||||
|
config *motr.Config
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
func broadcastTx(this js.Value, args []js.Value) interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func simulateTx(this js.Value, args []js.Value) interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func syncData(this js.Value, args []js.Value) interface{} {
|
||||||
|
if len(args) < 1 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
configString := args[0].String()
|
||||||
|
if err := json.Unmarshal([]byte(configString), &config); err != nil {
|
||||||
|
println("Error parsing config:", err.Error())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
// Load dwn config
|
||||||
|
js.Global().Set("broadcastTx", js.FuncOf(broadcastTx))
|
||||||
|
js.Global().Set("simulateTx", js.FuncOf(simulateTx))
|
||||||
|
js.Global().Set("syncData", js.FuncOf(syncData))
|
||||||
|
|
||||||
|
e := echo.New()
|
||||||
|
e.Use(wasm.ContextMiddleware)
|
||||||
|
// e.Use(controller.Middleware(nil))
|
||||||
|
vault.RegisterRoutes(e, config)
|
||||||
|
wasm.ServeFetch(e)
|
||||||
|
}
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
//go:build js && wasm
|
||||||
|
// +build js,wasm
|
||||||
|
|
||||||
|
package wasm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"syscall/js"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Global buffer pool to reduce allocations
|
||||||
|
bufferPool = sync.Pool{
|
||||||
|
New: func() interface{} {
|
||||||
|
return new(bytes.Buffer)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cached JS globals
|
||||||
|
jsGlobal = js.Global()
|
||||||
|
jsUint8Array = jsGlobal.Get("Uint8Array")
|
||||||
|
jsResponse = jsGlobal.Get("Response")
|
||||||
|
jsPromise = jsGlobal.Get("Promise")
|
||||||
|
jsWasmHTTP = jsGlobal.Get("wasmhttp")
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServeFetch serves HTTP requests with optimized handler management
|
||||||
|
func ServeFetch(handler http.Handler) func() {
|
||||||
|
h := handler
|
||||||
|
if h == nil {
|
||||||
|
h = http.DefaultServeMux
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optimize prefix handling
|
||||||
|
prefix := strings.TrimRight(jsWasmHTTP.Get("path").String(), "/")
|
||||||
|
if prefix != "" {
|
||||||
|
mux := http.NewServeMux()
|
||||||
|
mux.Handle(prefix+"/", http.StripPrefix(prefix, h))
|
||||||
|
h = mux
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create request handler function
|
||||||
|
cb := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||||
|
promise, resolve, reject := newPromiseOptimized()
|
||||||
|
|
||||||
|
go handleRequest(h, args[1], resolve, reject)
|
||||||
|
|
||||||
|
return promise
|
||||||
|
})
|
||||||
|
|
||||||
|
jsWasmHTTP.Call("setHandler", cb)
|
||||||
|
return cb.Release
|
||||||
|
}
|
||||||
|
|
||||||
|
// handleRequest processes the request with panic recovery
|
||||||
|
func handleRequest(h http.Handler, jsReq js.Value, resolve, reject func(interface{})) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
var errMsg string
|
||||||
|
if err, ok := r.(error); ok {
|
||||||
|
errMsg = fmt.Sprintf("wasmhttp: panic: %+v", err)
|
||||||
|
} else {
|
||||||
|
errMsg = fmt.Sprintf("wasmhttp: panic: %v", r)
|
||||||
|
}
|
||||||
|
reject(errMsg)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
recorder := newResponseRecorder()
|
||||||
|
h.ServeHTTP(recorder, buildRequest(jsReq))
|
||||||
|
resolve(recorder.jsResponse())
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildRequest creates an http.Request from JS Request
|
||||||
|
func buildRequest(jsReq js.Value) *http.Request {
|
||||||
|
// Get request body
|
||||||
|
arrayBuffer, err := awaitPromiseOptimized(jsReq.Call("arrayBuffer"))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create body buffer
|
||||||
|
jsBody := jsUint8Array.New(arrayBuffer)
|
||||||
|
bodyLen := jsBody.Get("length").Int()
|
||||||
|
body := make([]byte, bodyLen)
|
||||||
|
js.CopyBytesToGo(body, jsBody)
|
||||||
|
|
||||||
|
// Create request
|
||||||
|
req := httptest.NewRequest(
|
||||||
|
jsReq.Get("method").String(),
|
||||||
|
jsReq.Get("url").String(),
|
||||||
|
bytes.NewReader(body),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Set headers efficiently
|
||||||
|
headers := jsReq.Get("headers")
|
||||||
|
headersIt := headers.Call("entries")
|
||||||
|
for {
|
||||||
|
entry := headersIt.Call("next")
|
||||||
|
if entry.Get("done").Bool() {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
pair := entry.Get("value")
|
||||||
|
req.Header.Set(pair.Index(0).String(), pair.Index(1).String())
|
||||||
|
}
|
||||||
|
|
||||||
|
return req
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResponseRecorder with optimized buffer handling
|
||||||
|
type ResponseRecorder struct {
|
||||||
|
*httptest.ResponseRecorder
|
||||||
|
buffer *bytes.Buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
func newResponseRecorder() *ResponseRecorder {
|
||||||
|
return &ResponseRecorder{
|
||||||
|
ResponseRecorder: httptest.NewRecorder(),
|
||||||
|
buffer: bufferPool.Get().(*bytes.Buffer),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// jsResponse creates a JS Response with optimized memory usage
|
||||||
|
func (rr *ResponseRecorder) jsResponse() js.Value {
|
||||||
|
defer func() {
|
||||||
|
rr.buffer.Reset()
|
||||||
|
bufferPool.Put(rr.buffer)
|
||||||
|
}()
|
||||||
|
|
||||||
|
res := rr.Result()
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
// Prepare response body
|
||||||
|
body := js.Undefined()
|
||||||
|
if res.ContentLength != 0 {
|
||||||
|
if _, err := io.Copy(rr.buffer, res.Body); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
bodyBytes := rr.buffer.Bytes()
|
||||||
|
body = jsUint8Array.New(len(bodyBytes))
|
||||||
|
js.CopyBytesToJS(body, bodyBytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare response init object
|
||||||
|
init := make(map[string]interface{}, 3)
|
||||||
|
if res.StatusCode != 0 {
|
||||||
|
init["status"] = res.StatusCode
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(res.Header) > 0 {
|
||||||
|
headers := make(map[string]interface{}, len(res.Header))
|
||||||
|
for k, v := range res.Header {
|
||||||
|
if len(v) > 0 {
|
||||||
|
headers[k] = v[0]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
init["headers"] = headers
|
||||||
|
}
|
||||||
|
|
||||||
|
return jsResponse.New(body, init)
|
||||||
|
}
|
||||||
|
|
||||||
|
// newPromiseOptimized creates a new JavaScript Promise with optimized callback handling
|
||||||
|
func newPromiseOptimized() (js.Value, func(interface{}), func(interface{})) {
|
||||||
|
var (
|
||||||
|
resolve func(interface{})
|
||||||
|
reject func(interface{})
|
||||||
|
promiseFunc = js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||||
|
resolve = func(v interface{}) { args[0].Invoke(v) }
|
||||||
|
reject = func(v interface{}) { args[1].Invoke(v) }
|
||||||
|
return js.Undefined()
|
||||||
|
})
|
||||||
|
)
|
||||||
|
defer promiseFunc.Release()
|
||||||
|
|
||||||
|
return jsPromise.New(promiseFunc), resolve, reject
|
||||||
|
}
|
||||||
|
|
||||||
|
// awaitPromiseOptimized waits for Promise resolution with optimized channel handling
|
||||||
|
func awaitPromiseOptimized(promise js.Value) (js.Value, error) {
|
||||||
|
done := make(chan struct{})
|
||||||
|
var (
|
||||||
|
result js.Value
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
thenFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||||
|
result = args[0]
|
||||||
|
close(done)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
defer thenFunc.Release()
|
||||||
|
|
||||||
|
catchFunc := js.FuncOf(func(_ js.Value, args []js.Value) interface{} {
|
||||||
|
err = js.Error{Value: args[0]}
|
||||||
|
close(done)
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
defer catchFunc.Release()
|
||||||
|
|
||||||
|
promise.Call("then", thenFunc).Call("catch", catchFunc)
|
||||||
|
<-done
|
||||||
|
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
//go:build js && wasm
|
||||||
|
// +build js,wasm
|
||||||
|
|
||||||
|
package wasm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
|
)
|
||||||
|
|
||||||
|
func ContextMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
|
return func(c echo.Context) error {
|
||||||
|
// Extract WASM context from headers
|
||||||
|
if wasmCtx := c.Request().Header.Get("X-Wasm-Context"); wasmCtx != "" {
|
||||||
|
if ctx, err := DecodeWasmContext(wasmCtx); err == nil {
|
||||||
|
c.Set("wasm_context", ctx)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return next(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// decodeWasmContext decodes the WASM context from a base64 encoded string
|
||||||
|
func DecodeWasmContext(ctx string) (map[string]any, error) {
|
||||||
|
decoded, err := base64.StdEncoding.DecodeString(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var ctxData map[string]any
|
||||||
|
err = json.Unmarshal(decoded, &ctxData)
|
||||||
|
return ctxData, err
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ import (
|
|||||||
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
genutilcli "github.com/cosmos/cosmos-sdk/x/genutil/client/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO: Load this from PKL
|
||||||
// initCometBFTConfig helps to override default CometBFT Config values.
|
// initCometBFTConfig helps to override default CometBFT Config values.
|
||||||
// return cmtcfg.DefaultConfig if no custom configuration is required for the application.
|
// return cmtcfg.DefaultConfig if no custom configuration is required for the application.
|
||||||
func initCometBFTConfig() *cmtcfg.Config {
|
func initCometBFTConfig() *cmtcfg.Config {
|
||||||
@@ -46,12 +47,13 @@ func initCometBFTConfig() *cmtcfg.Config {
|
|||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Load this from PKL
|
||||||
// initAppConfig helps to override default appConfig template and configs.
|
// initAppConfig helps to override default appConfig template and configs.
|
||||||
// return "", nil if no custom configuration is required for the application.
|
// return "", nil if no custom configuration is required for the application.
|
||||||
func initAppConfig() (string, interface{}) {
|
func initAppConfig() (string, interface{}) {
|
||||||
// The following code snippet is just for reference.
|
// The following code snippet is just for reference.
|
||||||
|
|
||||||
type CustomAppConfig struct {
|
type SonrAppConfig struct {
|
||||||
serverconfig.Config
|
serverconfig.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ func initAppConfig() (string, interface{}) {
|
|||||||
srvCfg.MinGasPrices = "0stake"
|
srvCfg.MinGasPrices = "0stake"
|
||||||
// srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default
|
// srvCfg.BaseConfig.IAVLDisableFastNode = true // disable fastnode by default
|
||||||
|
|
||||||
customAppConfig := CustomAppConfig{
|
customAppConfig := SonrAppConfig{
|
||||||
Config: *srvCfg,
|
Config: *srvCfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -8,14 +8,11 @@ import (
|
|||||||
_ "github.com/joho/godotenv/autoload"
|
_ "github.com/joho/godotenv/autoload"
|
||||||
|
|
||||||
"github.com/onsonr/sonr/app"
|
"github.com/onsonr/sonr/app"
|
||||||
"github.com/onsonr/sonr/app/cli"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
rootCmd := NewRootCmd()
|
rootCmd := NewRootCmd()
|
||||||
rootCmd.AddCommand(cli.NewBuildTxnTUICmd())
|
rootCmd.AddCommand(newPklInitCmd())
|
||||||
rootCmd.AddCommand(cli.NewExplorerTUICmd())
|
|
||||||
|
|
||||||
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {
|
||||||
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
|
log.NewLogger(rootCmd.OutOrStderr()).Error("failure when running app", "err", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
package main
|
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/apple/pkl-go/pkl"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var configDir string
|
||||||
|
|
||||||
|
func newPklInitCmd() *cobra.Command {
|
||||||
|
cmd := &cobra.Command{
|
||||||
|
Use: "init-pkl",
|
||||||
|
Short: "Initialize the Sonrd configuration using PKL",
|
||||||
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
|
ctx := context.Background()
|
||||||
|
evaluator, err := pkl.NewEvaluator(ctx, pkl.PreconfiguredOptions)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer evaluator.Close()
|
||||||
|
|
||||||
|
appPath := formatConfigPath(cmd, "app.toml")
|
||||||
|
configPath := formatConfigPath(cmd, "config.toml")
|
||||||
|
|
||||||
|
// Create app.toml
|
||||||
|
if err := createAppToml(evaluator, appPath); err != nil {
|
||||||
|
cmd.PrintErrf("Failed to create app.toml: %v\n", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.Printf("Successfully created %s\n", appPath)
|
||||||
|
|
||||||
|
// Create config.toml
|
||||||
|
if err := createConfigToml(evaluator, configPath); err != nil {
|
||||||
|
cmd.PrintErrf("Failed to create config.toml: %v\n", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
cmd.Printf("Successfully created %s\n", configPath)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
cmd.Flags().StringVar(&configDir, "config-dir", "~/.sonr/config", "Path to where pkl files should be output")
|
||||||
|
return cmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func createAppToml(evaluator pkl.Evaluator, path string) error {
|
||||||
|
appSource := pkl.UriSource("https://pkl.sh/sonr.chain/0.0.2/App.pkl")
|
||||||
|
res, err := evaluator.EvaluateOutputText(context.Background(), appSource)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Printf("res: %s", res)
|
||||||
|
return writeConfigFile(path, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createConfigToml(evaluator pkl.Evaluator, path string) error {
|
||||||
|
configSource := pkl.UriSource("https://pkl.sh/sonr.chain/0.0.2/Config.pkl")
|
||||||
|
res, err := evaluator.EvaluateOutputText(context.Background(), configSource)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Printf("res: %s", res)
|
||||||
|
return writeConfigFile(path, res)
|
||||||
|
}
|
||||||
|
|
||||||
|
func formatConfigPath(cmd *cobra.Command, fileName string) string {
|
||||||
|
configDir := cmd.Flag("config-dir").Value.String()
|
||||||
|
// Expand home directory if needed
|
||||||
|
if configDir[:2] == "~/" {
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
if err == nil {
|
||||||
|
configDir = filepath.Join(home, configDir[2:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return filepath.Join(configDir, fileName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeConfigFile(path string, content string) error {
|
||||||
|
// Create the directory path if it doesn't exist
|
||||||
|
dir := filepath.Dir(path)
|
||||||
|
if err := os.MkdirAll(dir, 0o755); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if file already exists
|
||||||
|
if _, err := os.Stat(path); err == nil {
|
||||||
|
// File exists, create backup
|
||||||
|
backupPath := path + ".backup"
|
||||||
|
if err := os.Rename(path, backupPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write the new config file
|
||||||
|
return os.WriteFile(path, []byte(content), 0o644)
|
||||||
|
}
|
||||||
Executable
+171
@@ -0,0 +1,171 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package accumulator implements the cryptographic accumulator as described in https://eprint.iacr.org/2020/777.pdf
|
||||||
|
// It also implements the zero knowledge proof of knowledge protocol
|
||||||
|
// described in section 7 of the paper.
|
||||||
|
// Note: the paper only describes for non-membership witness case, but we don't
|
||||||
|
// use non-membership witness. We only implement the membership witness case.
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/go-bare"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
type structMarshal struct {
|
||||||
|
Curve string `bare:"curve"`
|
||||||
|
Value []byte `bare:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Element curves.Scalar
|
||||||
|
|
||||||
|
// Coefficient is a point
|
||||||
|
type Coefficient curves.Point
|
||||||
|
|
||||||
|
// Accumulator is a point
|
||||||
|
type Accumulator struct {
|
||||||
|
value curves.Point
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new accumulator.
|
||||||
|
func (acc *Accumulator) New(curve *curves.PairingCurve) (*Accumulator, error) {
|
||||||
|
// If we need to support non-membership witness, we need to implement Accumulator Initialization
|
||||||
|
// as described in section 6 of <https://eprint.iacr.org/2020/777.pdf>
|
||||||
|
// for now we don't need non-membership witness
|
||||||
|
|
||||||
|
// i.e., it computes V0 = prod(y + α) * P, y ∈ Y_V0, P is a generator of G1. Since we do not use non-membership witness
|
||||||
|
// we just set the initial accumulator a G1 generator.
|
||||||
|
acc.value = curve.Scalar.Point().Generator()
|
||||||
|
return acc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithElements initializes a new accumulator prefilled with entries
|
||||||
|
// Each member is assumed to be hashed
|
||||||
|
// V = prod(y + α) * V0, for all y∈ Y_V
|
||||||
|
func (acc *Accumulator) WithElements(curve *curves.PairingCurve, key *SecretKey, m []Element) (*Accumulator, error) {
|
||||||
|
_, err := acc.New(curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
y, err := key.BatchAdditions(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
acc.value = acc.value.Mul(y)
|
||||||
|
return acc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddElements accumulates a set of elements into the accumulator.
|
||||||
|
func (acc *Accumulator) AddElements(key *SecretKey, m []Element) (*Accumulator, error) {
|
||||||
|
if acc.value == nil || key.value == nil {
|
||||||
|
return nil, fmt.Errorf("accumulator and secret key should not be nil")
|
||||||
|
}
|
||||||
|
y, err := key.BatchAdditions(m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
acc.value = acc.value.Mul(y)
|
||||||
|
return acc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add accumulates a single element into the accumulator
|
||||||
|
// V' = (y + alpha) * V
|
||||||
|
func (acc *Accumulator) Add(key *SecretKey, e Element) (*Accumulator, error) {
|
||||||
|
if acc.value == nil || acc.value.IsIdentity() || key.value == nil || e == nil {
|
||||||
|
return nil, fmt.Errorf("accumulator, secret key and element should not be nil")
|
||||||
|
}
|
||||||
|
y := e.Add(key.value) // y + alpha
|
||||||
|
acc.value = acc.value.Mul(y)
|
||||||
|
return acc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove removes a single element from accumulator if it exists
|
||||||
|
// V' = 1/(y+alpha) * V
|
||||||
|
func (acc *Accumulator) Remove(key *SecretKey, e Element) (*Accumulator, error) {
|
||||||
|
if acc.value == nil || acc.value.IsIdentity() || key.value == nil || e == nil {
|
||||||
|
return nil, fmt.Errorf("accumulator, secret key and element should not be nil")
|
||||||
|
}
|
||||||
|
y := e.Add(key.value) // y + alpha
|
||||||
|
y, err := y.Invert() // 1/(y+alpha)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
acc.value = acc.value.Mul(y)
|
||||||
|
return acc, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update performs a batch addition and deletion as described on page 7, section 3 in
|
||||||
|
// https://eprint.iacr.org/2020/777.pdf
|
||||||
|
func (acc *Accumulator) Update(key *SecretKey, additions []Element, deletions []Element) (*Accumulator, []Coefficient, error) {
|
||||||
|
if acc.value == nil || acc.value.IsIdentity() || key.value == nil {
|
||||||
|
return nil, nil, fmt.Errorf("accumulator and secret key should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute dA(-alpha) = prod(y + alpha), y in the set of A ⊆ ACC-Y_V
|
||||||
|
a, err := key.BatchAdditions(additions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute dD(-alpha) = 1/prod(y + alpha), y in the set of D ⊆ Y_V
|
||||||
|
d, err := key.BatchDeletions(deletions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// dA(-alpha)/dD(-alpha)
|
||||||
|
div := a.Mul(d)
|
||||||
|
newAcc := acc.value.Mul(div)
|
||||||
|
|
||||||
|
// build an array of coefficients
|
||||||
|
elements, err := key.CreateCoefficients(additions, deletions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
coefficients := make([]Coefficient, len(elements))
|
||||||
|
for i := 0; i < len(elements); i++ {
|
||||||
|
coefficients[i] = acc.value.Mul(elements[i])
|
||||||
|
}
|
||||||
|
acc.value = newAcc
|
||||||
|
return acc, coefficients, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts Accumulator to bytes
|
||||||
|
func (acc Accumulator) MarshalBinary() ([]byte, error) {
|
||||||
|
if acc.value == nil {
|
||||||
|
return nil, fmt.Errorf("accumulator cannot be nil")
|
||||||
|
}
|
||||||
|
tv := &structMarshal{
|
||||||
|
Value: acc.value.ToAffineCompressed(),
|
||||||
|
Curve: acc.value.CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary sets Accumulator from bytes
|
||||||
|
func (acc *Accumulator) UnmarshalBinary(data []byte) error {
|
||||||
|
tv := new(structMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
|
||||||
|
value, err := curve.NewIdentityPoint().FromAffineCompressed(tv.Value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
acc.value = value
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Executable
+188
@@ -0,0 +1,188 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestNewAccumulator100(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc, err := new(Accumulator).New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
accBz, err := acc.MarshalBinary()
|
||||||
|
require.NoError(t, err)
|
||||||
|
fmt.Println(accBz)
|
||||||
|
fmt.Println(len(accBz))
|
||||||
|
fmt.Println(hex.EncodeToString(accBz))
|
||||||
|
fmt.Println(len(hex.EncodeToString(accBz)))
|
||||||
|
require.Equal(t, 60, len(accBz), "Marshalled accumulator should be 60 bytes")
|
||||||
|
require.Equal(t, 120, len(hex.EncodeToString(accBz)), "Hex-encoded accumulator should be 120 characters")
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewAccumulator10K(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc, err := new(Accumulator).New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewAccumulator10M(t *testing.T) {
|
||||||
|
// Initiating 10M values takes time
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping test in short mode.")
|
||||||
|
}
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc, err := new(Accumulator).New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestWithElements(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, _ := new(SecretKey).New(curve, seed[:])
|
||||||
|
element1 := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("value2"))
|
||||||
|
elements := []Element{element1, element2}
|
||||||
|
newAcc, err := new(Accumulator).WithElements(curve, key, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, newAcc)
|
||||||
|
require.NotEqual(t, newAcc.value.ToAffineCompressed(), curve.PointG1.Identity().ToAffineCompressed())
|
||||||
|
require.NotEqual(t, newAcc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
|
||||||
|
_, _ = newAcc.Remove(key, element1)
|
||||||
|
_, _ = newAcc.Remove(key, element2)
|
||||||
|
require.Equal(t, newAcc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAdd(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc := &Accumulator{curve.PointG1.Generator()}
|
||||||
|
_, _ = acc.New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
|
||||||
|
element := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, element)
|
||||||
|
_, _ = acc.Add(key, element)
|
||||||
|
require.NotEqual(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRemove(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc, err := new(Accumulator).New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
|
||||||
|
element := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, element)
|
||||||
|
|
||||||
|
// add element
|
||||||
|
_, _ = acc.Add(key, element)
|
||||||
|
require.NotEqual(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
|
||||||
|
// remove element
|
||||||
|
acc, err = acc.Remove(key, element)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddElements(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc := &Accumulator{curve.PointG1.Generator()}
|
||||||
|
_, _ = acc.New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
|
||||||
|
element1 := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("value2"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("value3"))
|
||||||
|
elements := []Element{element1, element2, element3}
|
||||||
|
|
||||||
|
acc, err = acc.AddElements(key, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotEqual(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAccumulatorMarshal(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
point := curve.PointG1.Generator().Mul(curve.Scalar.New(2))
|
||||||
|
data, err := Accumulator{point}.MarshalBinary()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, data)
|
||||||
|
// element cannot be empty
|
||||||
|
_, err = Accumulator{}.MarshalBinary()
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
|
e := &Accumulator{curve.PointG1.Generator()}
|
||||||
|
_ = e.UnmarshalBinary(data)
|
||||||
|
require.True(t, e.value.Equal(point))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdate(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, err := new(SecretKey).New(curve, seed[:])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, key)
|
||||||
|
acc, err := new(Accumulator).New(curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
|
||||||
|
element1 := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("value2"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("value3"))
|
||||||
|
elements := []Element{element1, element2, element3}
|
||||||
|
|
||||||
|
acc, _, err = acc.Update(key, elements, nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotEqual(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
|
||||||
|
acc, _, err = acc.Update(key, nil, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, acc.value.ToAffineCompressed(), curve.PointG1.Generator().ToAffineCompressed())
|
||||||
|
}
|
||||||
Executable
+244
@@ -0,0 +1,244 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/go-bare"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SecretKey is the secret alpha only held by the accumulator manager.
|
||||||
|
type SecretKey struct {
|
||||||
|
value curves.Scalar
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new secret key from the seed.
|
||||||
|
func (sk *SecretKey) New(curve *curves.PairingCurve, seed []byte) (*SecretKey, error) {
|
||||||
|
sk.value = curve.Scalar.Hash(seed)
|
||||||
|
return sk, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPublicKey creates a public key from SecretKey sk
|
||||||
|
func (sk SecretKey) GetPublicKey(curve *curves.PairingCurve) (*PublicKey, error) {
|
||||||
|
if sk.value == nil || curve == nil {
|
||||||
|
return nil, fmt.Errorf("curve and sk value cannot be nil")
|
||||||
|
}
|
||||||
|
value := curve.Scalar.Point().(curves.PairingPoint).OtherGroup().Generator().Mul(sk.value)
|
||||||
|
return &PublicKey{value.(curves.PairingPoint)}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts SecretKey to bytes
|
||||||
|
func (sk SecretKey) MarshalBinary() ([]byte, error) {
|
||||||
|
if sk.value == nil {
|
||||||
|
return nil, fmt.Errorf("sk cannot be empty")
|
||||||
|
}
|
||||||
|
tv := &structMarshal{
|
||||||
|
Value: sk.value.Bytes(),
|
||||||
|
Curve: sk.value.Point().CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary sets SecretKey from bytes
|
||||||
|
func (sk *SecretKey) UnmarshalBinary(data []byte) error {
|
||||||
|
tv := new(structMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
|
||||||
|
value, err := curve.NewScalar().SetBytes(tv.Value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sk.value = value
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BatchAdditions computes product(y + sk) for y in additions and output the product
|
||||||
|
func (sk SecretKey) BatchAdditions(additions []Element) (Element, error) {
|
||||||
|
if sk.value == nil {
|
||||||
|
return nil, fmt.Errorf("secret key cannot be empty")
|
||||||
|
}
|
||||||
|
mul := sk.value.One()
|
||||||
|
for i := 0; i < len(additions); i++ {
|
||||||
|
if additions[i] == nil {
|
||||||
|
return nil, fmt.Errorf("some element in additions is nil")
|
||||||
|
}
|
||||||
|
// y + alpha
|
||||||
|
temp := additions[i].Add(sk.value)
|
||||||
|
// prod(y + alpha)
|
||||||
|
mul = mul.Mul(temp)
|
||||||
|
}
|
||||||
|
return mul, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BatchDeletions computes 1/product(y + sk) for y in deletions and output it
|
||||||
|
func (sk SecretKey) BatchDeletions(deletions []Element) (Element, error) {
|
||||||
|
v, err := sk.BatchAdditions(deletions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
y, err := v.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return y, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateCoefficients creates the Batch Polynomial coefficients
|
||||||
|
// See page 7 of https://eprint.iacr.org/2020/777.pdf
|
||||||
|
func (sk SecretKey) CreateCoefficients(additions []Element, deletions []Element) ([]Element, error) {
|
||||||
|
if sk.value == nil {
|
||||||
|
return nil, fmt.Errorf("secret key should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
// vD(x) = ∑^{m}_{s=1}{ ∏ 1..s {yD_i + alpha}^-1 ∏ 1 ..s-1 {yD_j - x}
|
||||||
|
one := sk.value.One()
|
||||||
|
m1 := one.Neg() // m1 is -1
|
||||||
|
vD := make(polynomial, 0, len(deletions))
|
||||||
|
for s := 0; s < len(deletions); s++ {
|
||||||
|
// ∏ 1..s (yD_i + alpha)^-1
|
||||||
|
c, err := sk.BatchDeletions(deletions[0 : s+1])
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error in sk batchDeletions")
|
||||||
|
}
|
||||||
|
poly := make(polynomial, 1, s+2)
|
||||||
|
poly[0] = one
|
||||||
|
|
||||||
|
// ∏ 1..(s-1) (yD_j - x)
|
||||||
|
for j := 0; j < s; j++ {
|
||||||
|
t := make(polynomial, 2)
|
||||||
|
// yD_j
|
||||||
|
t[0] = deletions[j]
|
||||||
|
// -x
|
||||||
|
t[1] = m1
|
||||||
|
|
||||||
|
// polynomial multiplication (yD_1-x) * (yD_2 - x) ...
|
||||||
|
poly, err = poly.Mul(t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poly, err = poly.MulScalar(c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
vD, err = vD.Add(poly)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// vD(x) * ∏ 1..n (yA_i + alpha)
|
||||||
|
bAdd, err := sk.BatchAdditions(additions)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error in sk batchAdditions")
|
||||||
|
}
|
||||||
|
vD, err = vD.MulScalar(bAdd)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// vA(x) = ∑^n_{s=1}{ ∏ 1..s-1 {yA_i + alpha} ∏ s+1..n {yA_j - x} }
|
||||||
|
vA := make(polynomial, 0, len(additions))
|
||||||
|
for s := 0; s < len(additions); s++ {
|
||||||
|
// ∏ 1..s-1 {yA_i + alpha}
|
||||||
|
var c Element
|
||||||
|
if s == 0 {
|
||||||
|
c = one
|
||||||
|
} else {
|
||||||
|
c, err = sk.BatchAdditions(additions[0:s])
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poly := make(polynomial, 1, s+2)
|
||||||
|
poly[0] = one
|
||||||
|
|
||||||
|
// ∏ s+1..n {yA_j - x}
|
||||||
|
for j := s + 1; j < len(additions); j++ {
|
||||||
|
t := make(polynomial, 2)
|
||||||
|
t[0] = additions[j]
|
||||||
|
t[1] = m1
|
||||||
|
|
||||||
|
// polynomial multiplication (yA_1-x) * (yA_2 - x) ...
|
||||||
|
poly, err = poly.Mul(t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
poly, err = poly.MulScalar(c)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
vA, err = vA.Add(poly)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// vA - vD
|
||||||
|
vA, err = vA.Sub(vD)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := make([]Element, len(vA))
|
||||||
|
for i := 0; i < len(vA); i++ {
|
||||||
|
result[i] = vA[i]
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// PublicKey is the public key of accumulator, it should be sk * generator of G2
|
||||||
|
type PublicKey struct {
|
||||||
|
value curves.PairingPoint
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts PublicKey to bytes
|
||||||
|
func (pk PublicKey) MarshalBinary() ([]byte, error) {
|
||||||
|
if pk.value == nil {
|
||||||
|
return nil, fmt.Errorf("public key cannot be nil")
|
||||||
|
}
|
||||||
|
tv := &structMarshal{
|
||||||
|
Value: pk.value.ToAffineCompressed(),
|
||||||
|
Curve: pk.value.CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary sets PublicKey from bytes
|
||||||
|
func (pk *PublicKey) UnmarshalBinary(data []byte) error {
|
||||||
|
tv := new(structMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetPairingCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
|
||||||
|
value, err := curve.NewScalar().Point().FromAffineCompressed(tv.Value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var ok bool
|
||||||
|
pk.value, ok = value.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("can't convert to PairingPoint")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Executable
+88
@@ -0,0 +1,88 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSecretKeyMarshal(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
data, err := SecretKey{curve.Scalar.One()}.MarshalBinary()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, data)
|
||||||
|
e := &SecretKey{curve.Scalar.New(2)}
|
||||||
|
err = e.UnmarshalBinary(data)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, e.value.Bytes(), curve.Scalar.One().Bytes())
|
||||||
|
|
||||||
|
// element cannot be empty
|
||||||
|
_, err = SecretKey{}.MarshalBinary()
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPublicKeyMarshal(t *testing.T) {
|
||||||
|
// Actually test both toBytes() and from()
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk := &SecretKey{curve.Scalar.New(3)}
|
||||||
|
pk, _ := sk.GetPublicKey(curve)
|
||||||
|
pkBytes, err := pk.MarshalBinary()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, pkBytes)
|
||||||
|
|
||||||
|
pk2 := &PublicKey{}
|
||||||
|
err = pk2.UnmarshalBinary(pkBytes)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, pk.value.Equal(pk2.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestBatch(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
sk, _ := new(SecretKey).New(curve, seed[:])
|
||||||
|
element1 := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("value2"))
|
||||||
|
elements := []Element{element1, element2}
|
||||||
|
|
||||||
|
add, err := sk.BatchAdditions(elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, add)
|
||||||
|
|
||||||
|
del, err := sk.BatchDeletions(elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, del)
|
||||||
|
|
||||||
|
result := add.Mul(del)
|
||||||
|
require.Equal(t, result, curve.Scalar.One())
|
||||||
|
|
||||||
|
g1 := curve.PointG1.Generator()
|
||||||
|
acc := g1.Mul(add)
|
||||||
|
require.NotEqual(t, acc, g1)
|
||||||
|
acc = acc.Mul(del)
|
||||||
|
require.Equal(t, acc.ToAffineCompressed(), g1.ToAffineCompressed())
|
||||||
|
|
||||||
|
acc2 := g1.Mul(result)
|
||||||
|
require.True(t, acc2.Equal(g1))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCoefficient(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk, _ := new(SecretKey).New(curve, []byte("1234567890"))
|
||||||
|
element1 := curve.Scalar.Hash([]byte("value1"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("value2"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("value3"))
|
||||||
|
element4 := curve.Scalar.Hash([]byte("value4"))
|
||||||
|
element5 := curve.Scalar.Hash([]byte("value5"))
|
||||||
|
elements := []Element{element1, element2, element3, element4, element5}
|
||||||
|
coefficients, err := sk.CreateCoefficients(elements[0:2], elements[2:5])
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, len(coefficients), 3)
|
||||||
|
}
|
||||||
Executable
+204
@@ -0,0 +1,204 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"math"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// dad constructs two polynomials - dA(x) and dD(x)
|
||||||
|
// dA(y) = prod(y_A,t - y), t = 1...n
|
||||||
|
// dD(y) = prod(y_D,t - y), t = 1...n
|
||||||
|
func dad(values []Element, y Element) (Element, error) {
|
||||||
|
if values == nil || y == nil {
|
||||||
|
return nil, fmt.Errorf("curve, values or y should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, value := range values {
|
||||||
|
if value == nil {
|
||||||
|
return nil, fmt.Errorf("some element is nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result := y.One()
|
||||||
|
if len(values) == 1 {
|
||||||
|
a := values[0]
|
||||||
|
result = a.Sub(y)
|
||||||
|
} else {
|
||||||
|
for i := 0; i < len(values); i++ {
|
||||||
|
temp := values[i].Sub(y)
|
||||||
|
result = result.Mul(temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type polynomialPoint []curves.Point
|
||||||
|
|
||||||
|
// evaluate evaluates a PolynomialG1 on input x.
|
||||||
|
func (p polynomialPoint) evaluate(x curves.Scalar) (curves.Point, error) {
|
||||||
|
if p == nil {
|
||||||
|
return nil, fmt.Errorf("p cannot be empty")
|
||||||
|
}
|
||||||
|
for i := 0; i < len(p); i++ {
|
||||||
|
if p[i] == nil {
|
||||||
|
return nil, fmt.Errorf("some coefficient in p is nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pp := x
|
||||||
|
res := p[0]
|
||||||
|
for i := 1; i < len(p); i++ {
|
||||||
|
r := p[i].Mul(pp)
|
||||||
|
res = res.Add(r)
|
||||||
|
pp = pp.Mul(x)
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add adds two PolynomialG1
|
||||||
|
func (p polynomialPoint) Add(rhs polynomialPoint) (polynomialPoint, error) {
|
||||||
|
maxLen := int(math.Max(float64(len(p)), float64(len(rhs))))
|
||||||
|
|
||||||
|
result := make(polynomialPoint, maxLen)
|
||||||
|
|
||||||
|
for i, c := range p {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
result[i] = c.Add(c.Identity())
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, c := range rhs {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
if result[i] == nil {
|
||||||
|
result[i] = c.Add(c.Identity())
|
||||||
|
} else {
|
||||||
|
result[i] = result[i].Add(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mul for PolynomialG1 computes rhs * p, p is a polynomial, rhs is a value
|
||||||
|
func (p polynomialPoint) Mul(rhs curves.Scalar) (polynomialPoint, error) {
|
||||||
|
result := make(polynomialPoint, len(p))
|
||||||
|
|
||||||
|
for i, c := range p {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
result[i] = c.Mul(rhs)
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type polynomial []curves.Scalar
|
||||||
|
|
||||||
|
// Add adds two polynomials
|
||||||
|
func (p polynomial) Add(rhs polynomial) (polynomial, error) {
|
||||||
|
maxLen := int(math.Max(float64(len(p)), float64(len(rhs))))
|
||||||
|
result := make([]curves.Scalar, maxLen)
|
||||||
|
|
||||||
|
for i, c := range p {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
result[i] = c.Clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, c := range rhs {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
if result[i] == nil {
|
||||||
|
result[i] = c.Clone()
|
||||||
|
} else {
|
||||||
|
result[i] = result[i].Add(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sub computes p-rhs and returns
|
||||||
|
func (p polynomial) Sub(rhs polynomial) (polynomial, error) {
|
||||||
|
maxLen := int(math.Max(float64(len(p)), float64(len(rhs))))
|
||||||
|
result := make([]curves.Scalar, maxLen)
|
||||||
|
|
||||||
|
for i, c := range p {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
result[i] = c.Clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, c := range rhs {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("invalid coefficient at %d", i)
|
||||||
|
}
|
||||||
|
if result[i] == nil {
|
||||||
|
result[i] = c.Neg()
|
||||||
|
} else {
|
||||||
|
result[i] = result[i].Sub(c)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mul multiplies two polynomials - p * rhs
|
||||||
|
func (p polynomial) Mul(rhs polynomial) (polynomial, error) {
|
||||||
|
// Check for each coefficient that should not be nil
|
||||||
|
for i, c := range p {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("coefficient in p at %d is nil", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for i, c := range rhs {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("coefficient in rhs at %d is nil", i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m := len(p)
|
||||||
|
n := len(rhs)
|
||||||
|
|
||||||
|
// Initialize the product polynomial
|
||||||
|
prod := make(polynomial, m+n-1)
|
||||||
|
for i := 0; i < len(prod); i++ {
|
||||||
|
prod[i] = p[0].Zero()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply two polynomials term by term
|
||||||
|
for i, cp := range p {
|
||||||
|
for j, cr := range rhs {
|
||||||
|
temp := cp.Mul(cr)
|
||||||
|
prod[i+j] = prod[i+j].Add(temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return prod, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MulScalar computes p * rhs, where rhs is a scalar value
|
||||||
|
func (p polynomial) MulScalar(rhs curves.Scalar) (polynomial, error) {
|
||||||
|
result := make(polynomial, len(p))
|
||||||
|
for i, c := range p {
|
||||||
|
if c == nil {
|
||||||
|
return nil, fmt.Errorf("coefficient at %d is nil", i)
|
||||||
|
}
|
||||||
|
result[i] = c.Mul(rhs)
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
Executable
+404
@@ -0,0 +1,404 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEvaluatePolyG1(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(3)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
output1, err := poly.evaluate(curve.Scalar.New(1))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output1)
|
||||||
|
result1 := curve.PointG1.Generator().Mul(curve.Scalar.New(6))
|
||||||
|
require.Equal(t, output1.ToAffineCompressed(), result1.ToAffineCompressed())
|
||||||
|
|
||||||
|
output2, err := poly.evaluate(curve.Scalar.New(2))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output2)
|
||||||
|
result2 := curve.PointG1.Generator().Mul(curve.Scalar.New(11))
|
||||||
|
require.Equal(t, output2.ToAffineCompressed(), result2.ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestEvaluatePolyG1Error(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomialPoint{
|
||||||
|
nil,
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
_, err := poly.evaluate(curve.Scalar.New(1))
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddAssignPolyG1(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
// Test polynomial with equal length
|
||||||
|
poly1 := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(3)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
poly2 := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(3)),
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := poly1.Add(poly2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output)
|
||||||
|
result := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(4)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(4)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(4)),
|
||||||
|
}
|
||||||
|
for i := 0; i < len(output); i++ {
|
||||||
|
require.Equal(t, output[i].ToAffineCompressed(), result[i].ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test polynomials with unequal length
|
||||||
|
poly3 := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
}
|
||||||
|
output2, err := poly1.Add(poly3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output2)
|
||||||
|
result2 := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(4)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(4)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
require.Equal(t, len(output2), len(result2))
|
||||||
|
for i := 0; i < len(output2); i++ {
|
||||||
|
require.Equal(t, output2[i].ToAffineCompressed(), result2[i].ToAffineCompressed())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test polynomial with Capacity
|
||||||
|
poly4 := make(polynomialPoint, 0, 3)
|
||||||
|
poly5, err := poly4.Add(poly1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, len(poly5), len(poly1))
|
||||||
|
for i := 0; i < len(poly5); i++ {
|
||||||
|
require.Equal(t, poly5[i].ToAffineCompressed(), poly1[i].ToAffineCompressed())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddAssignPolyG1Error(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly1 := polynomialPoint{
|
||||||
|
nil,
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
poly2 := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(3)),
|
||||||
|
}
|
||||||
|
output, err := poly1.Add(poly2)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Nil(t, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMulAssignPolyG1(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(3)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
rhs := curve.Scalar.New(3)
|
||||||
|
output, err := poly.Mul(rhs)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output)
|
||||||
|
poly2 := polynomialPoint{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(9)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(6)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(3)),
|
||||||
|
}
|
||||||
|
for i := 0; i < len(poly2); i++ {
|
||||||
|
require.Equal(t, output[i].ToAffineCompressed(), poly2[i].ToAffineCompressed())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMulAssignPolyG1Error(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomialPoint{
|
||||||
|
nil,
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(2)),
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(1)),
|
||||||
|
}
|
||||||
|
rhs := curve.Scalar.New(3)
|
||||||
|
output, err := poly.Mul(rhs)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Nil(t, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPushPoly(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomial{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
scalar := curve.Scalar.New(4)
|
||||||
|
result := append(poly, scalar)
|
||||||
|
require.Equal(t, result[3], scalar)
|
||||||
|
|
||||||
|
// Push one more
|
||||||
|
scalar2 := curve.Scalar.New(5)
|
||||||
|
result2 := append(result, scalar2)
|
||||||
|
require.Equal(t, result2[4], scalar2)
|
||||||
|
|
||||||
|
// Push to a new polynomial
|
||||||
|
newPoly := polynomial{}
|
||||||
|
newPoly = append(newPoly, scalar)
|
||||||
|
require.Equal(t, newPoly[0], scalar)
|
||||||
|
newPoly = append(newPoly, scalar2)
|
||||||
|
require.Equal(t, newPoly[1], scalar2)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddAssignPoly(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
// Test polynomial with equal length
|
||||||
|
poly1 := polynomial{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
poly2 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := poly1.Add(poly2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output)
|
||||||
|
result := []curves.Scalar{
|
||||||
|
curve.Scalar.New(4),
|
||||||
|
curve.Scalar.New(4),
|
||||||
|
curve.Scalar.New(4),
|
||||||
|
}
|
||||||
|
for i := 0; i < len(output); i++ {
|
||||||
|
require.Equal(t, output[i], result[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test polynomials with unequal length
|
||||||
|
poly3 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
}
|
||||||
|
output2, err := poly1.Add(poly3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output2)
|
||||||
|
result2 := []curves.Scalar{
|
||||||
|
curve.Scalar.New(4),
|
||||||
|
curve.Scalar.New(4),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
require.Equal(t, len(output2), len(result2))
|
||||||
|
for i := 0; i < len(output2); i++ {
|
||||||
|
require.Equal(t, output2[i], result2[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestAddAssignPolyError(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
// Test polynomial with equal length
|
||||||
|
poly1 := polynomial{
|
||||||
|
nil,
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
poly2 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := poly1.Add(poly2)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Nil(t, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSubAssignPoly(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
// Test polynomial with equal length
|
||||||
|
poly1 := polynomial{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
poly2 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := poly1.Sub(poly2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output)
|
||||||
|
result := []curves.Scalar{
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(0),
|
||||||
|
curve.Scalar.New(-2),
|
||||||
|
}
|
||||||
|
for i := 0; i < len(output); i++ {
|
||||||
|
require.Equal(t, output[i].Bytes(), result[i].Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test polynomials with unequal length
|
||||||
|
poly3 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(4),
|
||||||
|
}
|
||||||
|
output2, err := poly1.Sub(poly3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output2)
|
||||||
|
result2 := []curves.Scalar{
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(0),
|
||||||
|
curve.Scalar.New(-2),
|
||||||
|
curve.Scalar.New(-4),
|
||||||
|
}
|
||||||
|
require.Equal(t, len(output2), len(result2))
|
||||||
|
for i := 0; i < len(output2); i++ {
|
||||||
|
require.Equal(t, output2[i].Bytes(), result2[i].Bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSubAssignPolyError(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly1 := polynomial{
|
||||||
|
nil,
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
poly2 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := poly1.Sub(poly2)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Nil(t, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMulAssignPoly(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
// Test polynomial with equal length
|
||||||
|
poly1 := polynomial{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
poly2 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
|
||||||
|
output, err := poly1.Mul(poly2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output)
|
||||||
|
result := []curves.Scalar{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(8),
|
||||||
|
curve.Scalar.New(14),
|
||||||
|
curve.Scalar.New(8),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
for i := 0; i < len(result); i++ {
|
||||||
|
require.Equal(t, output[i].Bytes(), result[i].Bytes())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test polynomials with unequal length
|
||||||
|
poly3 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
}
|
||||||
|
output2, err := poly1.Mul(poly3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output2)
|
||||||
|
result2 := []curves.Scalar{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(8),
|
||||||
|
curve.Scalar.New(5),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
}
|
||||||
|
require.Equal(t, len(output2), 4)
|
||||||
|
for i := 0; i < len(output2); i++ {
|
||||||
|
require.Equal(t, output2[i].Bytes(), result2[i].Bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMulAssignPolyError(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly1 := polynomial{
|
||||||
|
nil,
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
poly2 := polynomial{
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
output, err := poly1.Mul(poly2)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Nil(t, output)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMulValueAssignPoly(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomial{
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
rhs := curve.Scalar.New(3)
|
||||||
|
output, err := poly.MulScalar(rhs)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, output)
|
||||||
|
coefficients2 := []curves.Scalar{
|
||||||
|
curve.Scalar.New(9),
|
||||||
|
curve.Scalar.New(6),
|
||||||
|
curve.Scalar.New(3),
|
||||||
|
}
|
||||||
|
for i := 0; i < len(coefficients2); i++ {
|
||||||
|
require.Equal(t, output[i].Bytes(), coefficients2[i].Bytes())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMulValueAssignPolyError(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
poly := polynomial{
|
||||||
|
nil,
|
||||||
|
curve.Scalar.New(2),
|
||||||
|
curve.Scalar.New(1),
|
||||||
|
}
|
||||||
|
rhs := curve.Scalar.New(3)
|
||||||
|
output, err := poly.MulScalar(rhs)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.Nil(t, output)
|
||||||
|
}
|
||||||
Executable
+518
@@ -0,0 +1,518 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
crand "crypto/rand"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/go-bare"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
type proofParamsMarshal struct {
|
||||||
|
X []byte `bare:"x"`
|
||||||
|
Y []byte `bare:"y"`
|
||||||
|
Z []byte `bare:"z"`
|
||||||
|
Curve string `bare:"curve"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProofParams contains four distinct public generators of G1 - X, Y, Z
|
||||||
|
type ProofParams struct {
|
||||||
|
x, y, z curves.Point
|
||||||
|
}
|
||||||
|
|
||||||
|
// New samples X, Y, Z, K
|
||||||
|
func (p *ProofParams) New(curve *curves.PairingCurve, pk *PublicKey, entropy []byte) (*ProofParams, error) {
|
||||||
|
pkBytes, err := pk.MarshalBinary()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
prefix := bytes.Repeat([]byte{0xFF}, 32)
|
||||||
|
data := append(prefix, entropy...)
|
||||||
|
data = append(data, pkBytes...)
|
||||||
|
p.z = curve.Scalar.Point().Hash(data)
|
||||||
|
|
||||||
|
data[0] = 0xFE
|
||||||
|
p.y = curve.Scalar.Point().Hash(data)
|
||||||
|
|
||||||
|
data[0] = 0xFD
|
||||||
|
p.x = curve.Scalar.Point().Hash(data)
|
||||||
|
|
||||||
|
return p, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts ProofParams to bytes
|
||||||
|
func (p *ProofParams) MarshalBinary() ([]byte, error) {
|
||||||
|
if p.x == nil || p.y == nil || p.z == nil {
|
||||||
|
return nil, fmt.Errorf("some value x, y, or z is nil")
|
||||||
|
}
|
||||||
|
tv := &proofParamsMarshal{
|
||||||
|
X: p.x.ToAffineCompressed(),
|
||||||
|
Y: p.y.ToAffineCompressed(),
|
||||||
|
Z: p.z.ToAffineCompressed(),
|
||||||
|
Curve: p.x.CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary converts bytes to ProofParams
|
||||||
|
func (p *ProofParams) UnmarshalBinary(data []byte) error {
|
||||||
|
if data == nil {
|
||||||
|
return fmt.Errorf("expected non-zero byte sequence")
|
||||||
|
}
|
||||||
|
tv := new(proofParamsMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
x, err := curve.NewIdentityPoint().FromAffineCompressed(tv.X)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
y, err := curve.NewIdentityPoint().FromAffineCompressed(tv.Y)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
z, err := curve.NewIdentityPoint().FromAffineCompressed(tv.Z)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
p.x = x
|
||||||
|
p.y = y
|
||||||
|
p.z = z
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MembershipProofCommitting contains value computed in Proof of knowledge and
|
||||||
|
// Blinding phases as described in section 7 of https://eprint.iacr.org/2020/777.pdf
|
||||||
|
type MembershipProofCommitting struct {
|
||||||
|
eC curves.Point
|
||||||
|
tSigma curves.Point
|
||||||
|
tRho curves.Point
|
||||||
|
deltaSigma curves.Scalar
|
||||||
|
deltaRho curves.Scalar
|
||||||
|
blindingFactor curves.Scalar
|
||||||
|
rSigma curves.Scalar
|
||||||
|
rRho curves.Scalar
|
||||||
|
rDeltaSigma curves.Scalar
|
||||||
|
rDeltaRho curves.Scalar
|
||||||
|
sigma curves.Scalar
|
||||||
|
rho curves.Scalar
|
||||||
|
capRSigma curves.Point
|
||||||
|
capRRho curves.Point
|
||||||
|
capRDeltaSigma curves.Point
|
||||||
|
capRDeltaRho curves.Point
|
||||||
|
capRE curves.Scalar
|
||||||
|
accumulator curves.Point
|
||||||
|
witnessValue curves.Scalar
|
||||||
|
xG1 curves.Point
|
||||||
|
yG1 curves.Point
|
||||||
|
zG1 curves.Point
|
||||||
|
}
|
||||||
|
|
||||||
|
// New initiates values of MembershipProofCommitting
|
||||||
|
func (mpc *MembershipProofCommitting) New(
|
||||||
|
witness *MembershipWitness,
|
||||||
|
acc *Accumulator,
|
||||||
|
pp *ProofParams,
|
||||||
|
pk *PublicKey,
|
||||||
|
) (*MembershipProofCommitting, error) {
|
||||||
|
// Randomly select σ, ρ
|
||||||
|
sigma := witness.y.Random(crand.Reader)
|
||||||
|
rho := witness.y.Random(crand.Reader)
|
||||||
|
|
||||||
|
// E_C = C + (σ + ρ)Z
|
||||||
|
t := sigma
|
||||||
|
t = t.Add(rho)
|
||||||
|
eC := pp.z
|
||||||
|
eC = eC.Mul(t)
|
||||||
|
eC = eC.Add(witness.c)
|
||||||
|
|
||||||
|
// T_σ = σX
|
||||||
|
tSigma := pp.x
|
||||||
|
tSigma = tSigma.Mul(sigma)
|
||||||
|
|
||||||
|
// T_ρ = ρY
|
||||||
|
tRho := pp.y
|
||||||
|
tRho = tRho.Mul(rho)
|
||||||
|
|
||||||
|
// δ_σ = yσ
|
||||||
|
deltaSigma := witness.y
|
||||||
|
deltaSigma = deltaSigma.Mul(sigma)
|
||||||
|
|
||||||
|
// δ_ρ = yρ
|
||||||
|
deltaRho := witness.y
|
||||||
|
deltaRho = deltaRho.Mul(rho)
|
||||||
|
|
||||||
|
// Randomly pick r_σ,r_ρ,r_δσ,r_δρ
|
||||||
|
rY := witness.y.Random(crand.Reader)
|
||||||
|
rSigma := witness.y.Random(crand.Reader)
|
||||||
|
rRho := witness.y.Random(crand.Reader)
|
||||||
|
rDeltaSigma := witness.y.Random(crand.Reader)
|
||||||
|
rDeltaRho := witness.y.Random(crand.Reader)
|
||||||
|
|
||||||
|
// R_σ = r_σ X
|
||||||
|
capRSigma := pp.x
|
||||||
|
capRSigma = capRSigma.Mul(rSigma)
|
||||||
|
|
||||||
|
// R_ρ = ρY
|
||||||
|
capRRho := pp.y
|
||||||
|
capRRho = capRRho.Mul(rRho)
|
||||||
|
|
||||||
|
// R_δσ = r_y T_σ - r_δσ X
|
||||||
|
negX := pp.x
|
||||||
|
negX = negX.Neg()
|
||||||
|
capRDeltaSigma := tSigma.Mul(rY)
|
||||||
|
capRDeltaSigma = capRDeltaSigma.Add(negX.Mul(rDeltaSigma))
|
||||||
|
|
||||||
|
// R_δρ = r_y T_ρ - r_δρ Y
|
||||||
|
negY := pp.y
|
||||||
|
negY = negY.Neg()
|
||||||
|
capRDeltaRho := tRho.Mul(rY)
|
||||||
|
capRDeltaRho = capRDeltaRho.Add(negY.Mul(rDeltaRho))
|
||||||
|
|
||||||
|
// P~
|
||||||
|
g2 := pk.value.Generator()
|
||||||
|
|
||||||
|
// -r_δσ - r_δρ
|
||||||
|
exp := rDeltaSigma
|
||||||
|
exp = exp.Add(rDeltaRho)
|
||||||
|
exp = exp.Neg()
|
||||||
|
|
||||||
|
// -r_σ - r_ρ
|
||||||
|
exp2 := rSigma
|
||||||
|
exp2 = exp2.Add(rRho)
|
||||||
|
exp2 = exp2.Neg()
|
||||||
|
|
||||||
|
// rY * eC
|
||||||
|
rYeC := eC.Mul(rY)
|
||||||
|
|
||||||
|
// (-r_δσ - r_δρ)*Z
|
||||||
|
expZ := pp.z.Mul(exp)
|
||||||
|
|
||||||
|
// (-r_σ - r_ρ)*Z
|
||||||
|
exp2Z := pp.z.Mul(exp2)
|
||||||
|
|
||||||
|
// Prepare
|
||||||
|
rYeCPrep, ok := rYeC.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
g2Prep, ok := g2.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
expZPrep, ok := expZ.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
exp2ZPrep, ok := exp2Z.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
pkPrep := pk.value
|
||||||
|
|
||||||
|
// Pairing
|
||||||
|
capRE := g2Prep.MultiPairing(rYeCPrep, g2Prep, expZPrep, g2Prep, exp2ZPrep, pkPrep)
|
||||||
|
|
||||||
|
return &MembershipProofCommitting{
|
||||||
|
eC,
|
||||||
|
tSigma,
|
||||||
|
tRho,
|
||||||
|
deltaSigma,
|
||||||
|
deltaRho,
|
||||||
|
rY,
|
||||||
|
rSigma,
|
||||||
|
rRho,
|
||||||
|
rDeltaSigma,
|
||||||
|
rDeltaRho,
|
||||||
|
sigma,
|
||||||
|
rho,
|
||||||
|
capRSigma,
|
||||||
|
capRRho,
|
||||||
|
capRDeltaSigma,
|
||||||
|
capRDeltaRho,
|
||||||
|
capRE,
|
||||||
|
acc.value,
|
||||||
|
witness.y,
|
||||||
|
pp.x,
|
||||||
|
pp.y,
|
||||||
|
pp.z,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetChallenge returns bytes that need to be hashed for generating challenge.
|
||||||
|
// V || Ec || T_sigma || T_rho || R_E || R_sigma || R_rho || R_delta_sigma || R_delta_rho
|
||||||
|
func (mpc MembershipProofCommitting) GetChallengeBytes() []byte {
|
||||||
|
res := mpc.accumulator.ToAffineCompressed()
|
||||||
|
res = append(res, mpc.eC.ToAffineCompressed()...)
|
||||||
|
res = append(res, mpc.tSigma.ToAffineCompressed()...)
|
||||||
|
res = append(res, mpc.tRho.ToAffineCompressed()...)
|
||||||
|
res = append(res, mpc.capRE.Bytes()...)
|
||||||
|
res = append(res, mpc.capRSigma.ToAffineCompressed()...)
|
||||||
|
res = append(res, mpc.capRRho.ToAffineCompressed()...)
|
||||||
|
res = append(res, mpc.capRDeltaSigma.ToAffineCompressed()...)
|
||||||
|
res = append(res, mpc.capRDeltaRho.ToAffineCompressed()...)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenProof computes the s values for Fiat-Shamir and return the actual
|
||||||
|
// proof to be sent to the verifier given the challenge c.
|
||||||
|
func (mpc *MembershipProofCommitting) GenProof(c curves.Scalar) *MembershipProof {
|
||||||
|
// s_y = r_y + c*y
|
||||||
|
sY := schnorr(mpc.blindingFactor, mpc.witnessValue, c)
|
||||||
|
// s_σ = r_σ + c*σ
|
||||||
|
sSigma := schnorr(mpc.rSigma, mpc.sigma, c)
|
||||||
|
// s_ρ = r_ρ + c*ρ
|
||||||
|
sRho := schnorr(mpc.rRho, mpc.rho, c)
|
||||||
|
// s_δσ = rδσ + c*δ_σ
|
||||||
|
sDeltaSigma := schnorr(mpc.rDeltaSigma, mpc.deltaSigma, c)
|
||||||
|
// s_δρ = rδρ + c*δ_ρ
|
||||||
|
sDeltaRho := schnorr(mpc.rDeltaRho, mpc.deltaRho, c)
|
||||||
|
|
||||||
|
return &MembershipProof{
|
||||||
|
mpc.eC,
|
||||||
|
mpc.tSigma,
|
||||||
|
mpc.tRho,
|
||||||
|
sSigma,
|
||||||
|
sRho,
|
||||||
|
sDeltaSigma,
|
||||||
|
sDeltaRho,
|
||||||
|
sY,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func schnorr(r, v, challenge curves.Scalar) curves.Scalar {
|
||||||
|
res := v
|
||||||
|
res = res.Mul(challenge)
|
||||||
|
res = res.Add(r)
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
|
type membershipProofMarshal struct {
|
||||||
|
EC []byte `bare:"e_c"`
|
||||||
|
TSigma []byte `bare:"t_sigma"`
|
||||||
|
TRho []byte `bare:"t_rho"`
|
||||||
|
SSigma []byte `bare:"s_sigma"`
|
||||||
|
SRho []byte `bare:"s_rho"`
|
||||||
|
SDeltaSigma []byte `bare:"s_delta_sigma"`
|
||||||
|
SDeltaRho []byte `bare:"s_delta_rho"`
|
||||||
|
SY []byte `bare:"s_y"`
|
||||||
|
Curve string `bare:"curve"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MembershipProof contains values in the proof to be verified
|
||||||
|
type MembershipProof struct {
|
||||||
|
eC curves.Point
|
||||||
|
tSigma curves.Point
|
||||||
|
tRho curves.Point
|
||||||
|
sSigma curves.Scalar
|
||||||
|
sRho curves.Scalar
|
||||||
|
sDeltaSigma curves.Scalar
|
||||||
|
sDeltaRho curves.Scalar
|
||||||
|
sY curves.Scalar
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finalize computes values in the proof to be verified.
|
||||||
|
func (mp *MembershipProof) Finalize(acc *Accumulator, pp *ProofParams, pk *PublicKey, challenge curves.Scalar) (*MembershipProofFinal, error) {
|
||||||
|
// R_σ = s_δ X + c T_σ
|
||||||
|
negTSigma := mp.tSigma
|
||||||
|
negTSigma = negTSigma.Neg()
|
||||||
|
capRSigma := pp.x.Mul(mp.sSigma)
|
||||||
|
capRSigma = capRSigma.Add(negTSigma.Mul(challenge))
|
||||||
|
|
||||||
|
// R_ρ = s_ρ Y + c T_ρ
|
||||||
|
negTRho := mp.tRho
|
||||||
|
negTRho = negTRho.Neg()
|
||||||
|
capRRho := pp.y.Mul(mp.sRho)
|
||||||
|
capRRho = capRRho.Add(negTRho.Mul(challenge))
|
||||||
|
|
||||||
|
// R_δσ = s_y T_σ - s_δσ X
|
||||||
|
negX := pp.x
|
||||||
|
negX = negX.Neg()
|
||||||
|
capRDeltaSigma := mp.tSigma.Mul(mp.sY)
|
||||||
|
capRDeltaSigma = capRDeltaSigma.Add(negX.Mul(mp.sDeltaSigma))
|
||||||
|
|
||||||
|
// R_δρ = s_y T_ρ - s_δρ Y
|
||||||
|
negY := pp.y
|
||||||
|
negY = negY.Neg()
|
||||||
|
capRDeltaRho := mp.tRho.Mul(mp.sY)
|
||||||
|
capRDeltaRho = capRDeltaRho.Add(negY.Mul(mp.sDeltaRho))
|
||||||
|
|
||||||
|
// tildeP
|
||||||
|
g2 := pk.value.Generator()
|
||||||
|
|
||||||
|
// Compute capRE, the pairing
|
||||||
|
// E_c * s_y
|
||||||
|
eCsY := mp.eC.Mul(mp.sY)
|
||||||
|
|
||||||
|
// (-s_delta_sigma - s_delta_rho) * Z
|
||||||
|
exp := mp.sDeltaSigma
|
||||||
|
exp = exp.Add(mp.sDeltaRho)
|
||||||
|
exp = exp.Neg()
|
||||||
|
expZ := pp.z.Mul(exp)
|
||||||
|
|
||||||
|
// (-c) * V
|
||||||
|
exp = challenge.Neg()
|
||||||
|
expV := acc.value.Mul(exp)
|
||||||
|
|
||||||
|
// E_c * s_y + (-s_delta_sigma - s_delta_rho) * Z + (-c) * V
|
||||||
|
lhs := eCsY.Add(expZ).Add(expV)
|
||||||
|
|
||||||
|
// (-s_sigma - s_rho) * Z
|
||||||
|
exp = mp.sSigma
|
||||||
|
exp = exp.Add(mp.sRho)
|
||||||
|
exp = exp.Neg()
|
||||||
|
expZ2 := pp.z.Mul(exp)
|
||||||
|
|
||||||
|
// E_c * c
|
||||||
|
cEc := mp.eC.Mul(challenge)
|
||||||
|
|
||||||
|
// (-s_sigma - s_rho) * Z + E_c * c
|
||||||
|
rhs := cEc.Add(expZ2)
|
||||||
|
|
||||||
|
// Prepare
|
||||||
|
lhsPrep, ok := lhs.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
g2Prep, ok := g2.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
rhsPrep, ok := rhs.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return nil, errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
pkPrep := pk.value
|
||||||
|
|
||||||
|
// capRE
|
||||||
|
capRE := g2Prep.MultiPairing(lhsPrep, g2Prep, rhsPrep, pkPrep)
|
||||||
|
|
||||||
|
return &MembershipProofFinal{
|
||||||
|
acc.value,
|
||||||
|
mp.eC,
|
||||||
|
mp.tSigma,
|
||||||
|
mp.tRho,
|
||||||
|
capRE,
|
||||||
|
capRSigma,
|
||||||
|
capRRho,
|
||||||
|
capRDeltaSigma,
|
||||||
|
capRDeltaRho,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts MembershipProof to bytes
|
||||||
|
func (mp MembershipProof) MarshalBinary() ([]byte, error) {
|
||||||
|
tv := &membershipProofMarshal{
|
||||||
|
EC: mp.eC.ToAffineCompressed(),
|
||||||
|
TSigma: mp.tSigma.ToAffineCompressed(),
|
||||||
|
TRho: mp.tRho.ToAffineCompressed(),
|
||||||
|
SSigma: mp.sSigma.Bytes(),
|
||||||
|
SRho: mp.sRho.Bytes(),
|
||||||
|
SDeltaSigma: mp.sDeltaSigma.Bytes(),
|
||||||
|
SDeltaRho: mp.sDeltaRho.Bytes(),
|
||||||
|
SY: mp.sY.Bytes(),
|
||||||
|
Curve: mp.eC.CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary converts bytes to MembershipProof
|
||||||
|
func (mp *MembershipProof) UnmarshalBinary(data []byte) error {
|
||||||
|
if data == nil {
|
||||||
|
return fmt.Errorf("expected non-zero byte sequence")
|
||||||
|
}
|
||||||
|
tv := new(membershipProofMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
eC, err := curve.NewIdentityPoint().FromAffineCompressed(tv.EC)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tSigma, err := curve.NewIdentityPoint().FromAffineCompressed(tv.TSigma)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tRho, err := curve.NewIdentityPoint().FromAffineCompressed(tv.TRho)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sSigma, err := curve.NewScalar().SetBytes(tv.SSigma)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sRho, err := curve.NewScalar().SetBytes(tv.SRho)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sDeltaSigma, err := curve.NewScalar().SetBytes(tv.SDeltaSigma)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sDeltaRho, err := curve.NewScalar().SetBytes(tv.SDeltaRho)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
sY, err := curve.NewScalar().SetBytes(tv.SY)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.eC = eC
|
||||||
|
mp.tSigma = tSigma
|
||||||
|
mp.tRho = tRho
|
||||||
|
mp.sSigma = sSigma
|
||||||
|
mp.sRho = sRho
|
||||||
|
mp.sDeltaSigma = sDeltaSigma
|
||||||
|
mp.sDeltaRho = sDeltaRho
|
||||||
|
mp.sY = sY
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MembershipProofFinal contains values that are input to Fiat-Shamir Heuristic
|
||||||
|
type MembershipProofFinal struct {
|
||||||
|
accumulator curves.Point
|
||||||
|
eC curves.Point
|
||||||
|
tSigma curves.Point
|
||||||
|
tRho curves.Point
|
||||||
|
capRE curves.Scalar
|
||||||
|
capRSigma curves.Point
|
||||||
|
capRRho curves.Point
|
||||||
|
capRDeltaSigma curves.Point
|
||||||
|
capRDeltaRho curves.Point
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetChallenge computes Fiat-Shamir Heuristic taking input values of MembershipProofFinal
|
||||||
|
func (m MembershipProofFinal) GetChallenge(curve *curves.PairingCurve) curves.Scalar {
|
||||||
|
res := m.accumulator.ToAffineCompressed()
|
||||||
|
res = append(res, m.eC.ToAffineCompressed()...)
|
||||||
|
res = append(res, m.tSigma.ToAffineCompressed()...)
|
||||||
|
res = append(res, m.tRho.ToAffineCompressed()...)
|
||||||
|
res = append(res, m.capRE.Bytes()...)
|
||||||
|
res = append(res, m.capRSigma.ToAffineCompressed()...)
|
||||||
|
res = append(res, m.capRRho.ToAffineCompressed()...)
|
||||||
|
res = append(res, m.capRDeltaSigma.ToAffineCompressed()...)
|
||||||
|
res = append(res, m.capRDeltaRho.ToAffineCompressed()...)
|
||||||
|
challenge := curve.Scalar.Hash(res)
|
||||||
|
return challenge
|
||||||
|
}
|
||||||
Executable
+182
@@ -0,0 +1,182 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestProofParamsMarshal(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk, _ := new(SecretKey).New(curve, []byte("1234567890"))
|
||||||
|
pk, _ := sk.GetPublicKey(curve)
|
||||||
|
|
||||||
|
params, err := new(ProofParams).New(curve, pk, []byte("entropy"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, params.x)
|
||||||
|
require.NotNil(t, params.y)
|
||||||
|
require.NotNil(t, params.z)
|
||||||
|
|
||||||
|
bytes, err := params.MarshalBinary()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, bytes)
|
||||||
|
|
||||||
|
params2 := &ProofParams{
|
||||||
|
curve.PointG1.Generator(),
|
||||||
|
curve.PointG1.Generator(),
|
||||||
|
curve.PointG1.Generator(),
|
||||||
|
}
|
||||||
|
err = params2.UnmarshalBinary(bytes)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, params.x.Equal(params2.x))
|
||||||
|
require.True(t, params.y.Equal(params2.y))
|
||||||
|
require.True(t, params.z.Equal(params2.z))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMembershipProof(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk, _ := new(SecretKey).New(curve, []byte("1234567890"))
|
||||||
|
pk, _ := sk.GetPublicKey(curve)
|
||||||
|
|
||||||
|
element1 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
element4 := curve.Scalar.Hash([]byte("6"))
|
||||||
|
element5 := curve.Scalar.Hash([]byte("7"))
|
||||||
|
element6 := curve.Scalar.Hash([]byte("8"))
|
||||||
|
element7 := curve.Scalar.Hash([]byte("9"))
|
||||||
|
elements := []Element{element1, element2, element3, element4, element5, element6, element7}
|
||||||
|
|
||||||
|
// Initiate a new accumulator
|
||||||
|
acc, err := new(Accumulator).WithElements(curve, sk, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc.value)
|
||||||
|
|
||||||
|
// Initiate a new membership witness for value elements[3]
|
||||||
|
wit, err := new(MembershipWitness).New(elements[3], acc, sk)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, wit.y, elements[3])
|
||||||
|
|
||||||
|
// Create proof parameters, which contains randomly sampled G1 points X, Y, Z, K
|
||||||
|
params, err := new(ProofParams).New(curve, pk, []byte("entropy"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, params.x)
|
||||||
|
require.NotNil(t, params.y)
|
||||||
|
require.NotNil(t, params.z)
|
||||||
|
|
||||||
|
mpc, err := new(MembershipProofCommitting).New(wit, acc, params, pk)
|
||||||
|
require.NoError(t, err)
|
||||||
|
testMPC(t, mpc)
|
||||||
|
|
||||||
|
challenge := curve.Scalar.Hash(mpc.GetChallengeBytes())
|
||||||
|
require.NotNil(t, challenge)
|
||||||
|
|
||||||
|
proof := mpc.GenProof(challenge)
|
||||||
|
require.NotNil(t, proof)
|
||||||
|
testProof(t, proof)
|
||||||
|
|
||||||
|
finalProof, err := proof.Finalize(acc, params, pk, challenge)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, finalProof)
|
||||||
|
testFinalProof(t, finalProof)
|
||||||
|
|
||||||
|
challenge2 := finalProof.GetChallenge(curve)
|
||||||
|
require.Equal(t, challenge, challenge2)
|
||||||
|
|
||||||
|
// Check we can still have a valid proof even if accumulator and witness are updated
|
||||||
|
data1 := curve.Scalar.Hash([]byte("1"))
|
||||||
|
data2 := curve.Scalar.Hash([]byte("2"))
|
||||||
|
data3 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
data4 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
data5 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
data := []Element{data1, data2, data3, data4, data5}
|
||||||
|
additions := data[0:2]
|
||||||
|
deletions := data[2:5]
|
||||||
|
_, coefficients, err := acc.Update(sk, additions, deletions)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, coefficients)
|
||||||
|
|
||||||
|
_, err = wit.BatchUpdate(additions, deletions, coefficients)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
newParams, err := new(ProofParams).New(curve, pk, []byte("entropy"))
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, newParams.x)
|
||||||
|
require.NotNil(t, newParams.y)
|
||||||
|
require.NotNil(t, newParams.z)
|
||||||
|
|
||||||
|
newMPC, err := new(MembershipProofCommitting).New(wit, acc, newParams, pk)
|
||||||
|
require.NoError(t, err)
|
||||||
|
testMPC(t, newMPC)
|
||||||
|
|
||||||
|
challenge3 := curve.Scalar.Hash(newMPC.GetChallengeBytes())
|
||||||
|
require.NotNil(t, challenge3)
|
||||||
|
|
||||||
|
newProof := newMPC.GenProof(challenge3)
|
||||||
|
require.NotNil(t, newProof)
|
||||||
|
testProof(t, newProof)
|
||||||
|
|
||||||
|
newFinalProof, err := newProof.Finalize(acc, newParams, pk, challenge3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, newFinalProof)
|
||||||
|
testFinalProof(t, newFinalProof)
|
||||||
|
|
||||||
|
challenge4 := newFinalProof.GetChallenge(curve)
|
||||||
|
require.Equal(t, challenge3, challenge4)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMPC(t *testing.T, mpc *MembershipProofCommitting) {
|
||||||
|
require.NotNil(t, mpc.eC)
|
||||||
|
require.NotNil(t, mpc.tSigma)
|
||||||
|
require.NotNil(t, mpc.tRho)
|
||||||
|
require.NotNil(t, mpc.deltaSigma)
|
||||||
|
require.NotNil(t, mpc.deltaRho)
|
||||||
|
require.NotNil(t, mpc.blindingFactor)
|
||||||
|
require.NotNil(t, mpc.rSigma)
|
||||||
|
require.NotNil(t, mpc.rRho)
|
||||||
|
require.NotNil(t, mpc.rDeltaSigma)
|
||||||
|
require.NotNil(t, mpc.rDeltaRho)
|
||||||
|
require.NotNil(t, mpc.sigma)
|
||||||
|
require.NotNil(t, mpc.rho)
|
||||||
|
require.NotNil(t, mpc.capRSigma)
|
||||||
|
require.NotNil(t, mpc.capRRho)
|
||||||
|
require.NotNil(t, mpc.capRDeltaSigma)
|
||||||
|
require.NotNil(t, mpc.capRDeltaRho)
|
||||||
|
require.NotNil(t, mpc.capRE)
|
||||||
|
require.NotNil(t, mpc.accumulator)
|
||||||
|
require.NotNil(t, mpc.witnessValue)
|
||||||
|
require.NotNil(t, mpc.xG1)
|
||||||
|
require.NotNil(t, mpc.yG1)
|
||||||
|
require.NotNil(t, mpc.zG1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testProof(t *testing.T, proof *MembershipProof) {
|
||||||
|
require.NotNil(t, proof.eC)
|
||||||
|
require.NotNil(t, proof.tSigma)
|
||||||
|
require.NotNil(t, proof.tRho)
|
||||||
|
require.NotNil(t, proof.sSigma)
|
||||||
|
require.NotNil(t, proof.sRho)
|
||||||
|
require.NotNil(t, proof.sDeltaSigma)
|
||||||
|
require.NotNil(t, proof.sDeltaRho)
|
||||||
|
require.NotNil(t, proof.sY)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testFinalProof(t *testing.T, finalProof *MembershipProofFinal) {
|
||||||
|
require.NotNil(t, finalProof.accumulator)
|
||||||
|
require.NotNil(t, finalProof.eC)
|
||||||
|
require.NotNil(t, finalProof.tSigma)
|
||||||
|
require.NotNil(t, finalProof.tRho)
|
||||||
|
require.NotNil(t, finalProof.capRE)
|
||||||
|
require.NotNil(t, finalProof.capRSigma)
|
||||||
|
require.NotNil(t, finalProof.capRRho)
|
||||||
|
require.NotNil(t, finalProof.capRDeltaSigma)
|
||||||
|
require.NotNil(t, finalProof.capRDeltaRho)
|
||||||
|
}
|
||||||
Executable
+375
@@ -0,0 +1,375 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.sr.ht/~sircmpwn/go-bare"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MembershipWitness contains the witness c and the value y respect to the accumulator state.
|
||||||
|
type MembershipWitness struct {
|
||||||
|
c curves.Point
|
||||||
|
y curves.Scalar
|
||||||
|
}
|
||||||
|
|
||||||
|
// New creates a new membership witness
|
||||||
|
func (mw *MembershipWitness) New(y Element, acc *Accumulator, sk *SecretKey) (*MembershipWitness, error) {
|
||||||
|
if acc.value == nil || acc.value.IsIdentity() {
|
||||||
|
return nil, fmt.Errorf("value of accumulator should not be nil")
|
||||||
|
}
|
||||||
|
if sk.value == nil || sk.value.IsZero() {
|
||||||
|
return nil, fmt.Errorf("secret key should not be nil")
|
||||||
|
}
|
||||||
|
if y == nil || y.IsZero() {
|
||||||
|
return nil, fmt.Errorf("y should not be nil")
|
||||||
|
}
|
||||||
|
newAcc := &Accumulator{acc.value}
|
||||||
|
_, err := newAcc.Remove(sk, y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mw.c = newAcc.value
|
||||||
|
mw.y = y.Add(y.Zero())
|
||||||
|
return mw, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify the MembershipWitness mw is a valid witness as per section 4 in
|
||||||
|
// <https://eprint.iacr.org/2020/777>
|
||||||
|
func (mw MembershipWitness) Verify(pk *PublicKey, acc *Accumulator) error {
|
||||||
|
if mw.c == nil || mw.y == nil || mw.c.IsIdentity() || mw.y.IsZero() {
|
||||||
|
return fmt.Errorf("c and y should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
if pk.value == nil || pk.value.IsIdentity() {
|
||||||
|
return fmt.Errorf("invalid public key")
|
||||||
|
}
|
||||||
|
if acc.value == nil || acc.value.IsIdentity() {
|
||||||
|
return fmt.Errorf("accumulator value should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set -tildeP
|
||||||
|
g2, ok := pk.value.Generator().(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
|
||||||
|
// y*tildeP + tildeQ, tildeP is a G2 generator.
|
||||||
|
p, ok := g2.Mul(mw.y).Add(pk.value).(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prepare
|
||||||
|
witness, ok := mw.c.(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
v, ok := acc.value.Neg().(curves.PairingPoint)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("incorrect type conversion")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check e(witness, y*tildeP + tildeQ) * e(-acc, tildeP) == Identity
|
||||||
|
result := p.MultiPairing(witness, p, v, g2)
|
||||||
|
if !result.IsOne() {
|
||||||
|
return fmt.Errorf("invalid result")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ApplyDelta returns C' = dA(y)/dD(y)*C + 1/dD(y) * <Gamma_y, Omega>
|
||||||
|
// according to the witness update protocol described in section 4 of
|
||||||
|
// https://eprint.iacr.org/2020/777.pdf
|
||||||
|
func (mw *MembershipWitness) ApplyDelta(delta *Delta) (*MembershipWitness, error) {
|
||||||
|
if mw.c == nil || mw.y == nil || delta == nil {
|
||||||
|
return nil, fmt.Errorf("y, c or delta should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
// C' = dA(y)/dD(y)*C + 1/dD(y) * <Gamma_y, Omega>
|
||||||
|
mw.c = mw.c.Mul(delta.d).Add(delta.p)
|
||||||
|
return mw, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// BatchUpdate performs batch update as described in section 4
|
||||||
|
func (mw *MembershipWitness) BatchUpdate(additions []Element, deletions []Element, coefficients []Coefficient) (*MembershipWitness, error) {
|
||||||
|
delta, err := evaluateDelta(mw.y, additions, deletions, coefficients)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
mw, err = mw.ApplyDelta(delta)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("applyDelta fails")
|
||||||
|
}
|
||||||
|
return mw, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MultiBatchUpdate performs multi-batch update using epoch as described in section 4.2
|
||||||
|
func (mw *MembershipWitness) MultiBatchUpdate(A [][]Element, D [][]Element, C [][]Coefficient) (*MembershipWitness, error) {
|
||||||
|
delta, err := evaluateDeltas(mw.y, A, D, C)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("evaluateDeltas fails")
|
||||||
|
}
|
||||||
|
mw, err = mw.ApplyDelta(delta)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return mw, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts a membership witness to bytes
|
||||||
|
func (mw MembershipWitness) MarshalBinary() ([]byte, error) {
|
||||||
|
if mw.c == nil || mw.y == nil {
|
||||||
|
return nil, fmt.Errorf("c and y value should not be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
result := append(mw.c.ToAffineCompressed(), mw.y.Bytes()...)
|
||||||
|
tv := &structMarshal{
|
||||||
|
Value: result,
|
||||||
|
Curve: mw.c.CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary converts bytes into MembershipWitness
|
||||||
|
func (mw *MembershipWitness) UnmarshalBinary(data []byte) error {
|
||||||
|
if data == nil {
|
||||||
|
return fmt.Errorf("input data should not be nil")
|
||||||
|
}
|
||||||
|
tv := new(structMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
|
||||||
|
ptLength := len(curve.Point.ToAffineCompressed())
|
||||||
|
scLength := len(curve.Scalar.Bytes())
|
||||||
|
expectedLength := ptLength + scLength
|
||||||
|
if len(tv.Value) != expectedLength {
|
||||||
|
return fmt.Errorf("invalid byte sequence")
|
||||||
|
}
|
||||||
|
cValue, err := curve.Point.FromAffineCompressed(tv.Value[:ptLength])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
yValue, err := curve.Scalar.SetBytes(tv.Value[ptLength:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mw.c = cValue
|
||||||
|
mw.y = yValue
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delta contains values d and p, where d should be the division dA(y)/dD(y) on some value y
|
||||||
|
// p should be equal to 1/dD * <Gamma_y, Omega>
|
||||||
|
type Delta struct {
|
||||||
|
d curves.Scalar
|
||||||
|
p curves.Point
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary converts Delta into bytes
|
||||||
|
func (d *Delta) MarshalBinary() ([]byte, error) {
|
||||||
|
if d.d == nil || d.p == nil {
|
||||||
|
return nil, fmt.Errorf("d and p should not be nil")
|
||||||
|
}
|
||||||
|
var result []byte
|
||||||
|
result = append(result, d.p.ToAffineCompressed()...)
|
||||||
|
result = append(result, d.d.Bytes()...)
|
||||||
|
tv := &structMarshal{
|
||||||
|
Value: result,
|
||||||
|
Curve: d.p.CurveName(),
|
||||||
|
}
|
||||||
|
return bare.Marshal(tv)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary converts data into Delta
|
||||||
|
func (d *Delta) UnmarshalBinary(data []byte) error {
|
||||||
|
if data == nil {
|
||||||
|
return fmt.Errorf("expected non-zero byte sequence")
|
||||||
|
}
|
||||||
|
|
||||||
|
tv := new(structMarshal)
|
||||||
|
err := bare.Unmarshal(data, tv)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
curve := curves.GetCurveByName(tv.Curve)
|
||||||
|
if curve == nil {
|
||||||
|
return fmt.Errorf("invalid curve")
|
||||||
|
}
|
||||||
|
|
||||||
|
ptLength := len(curve.Point.ToAffineCompressed())
|
||||||
|
scLength := len(curve.Scalar.Bytes())
|
||||||
|
expectedLength := ptLength + scLength
|
||||||
|
if len(tv.Value) != expectedLength {
|
||||||
|
return fmt.Errorf("invalid byte sequence")
|
||||||
|
}
|
||||||
|
pValue, err := curve.NewIdentityPoint().FromAffineCompressed(tv.Value[:ptLength])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
dValue, err := curve.NewScalar().SetBytes(tv.Value[ptLength:])
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d.d = dValue
|
||||||
|
d.p = pValue
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// evaluateDeltas compute values used for membership witness batch update with epoch
|
||||||
|
// as described in section 4.2, page 11 of https://eprint.iacr.org/2020/777.pdf
|
||||||
|
func evaluateDeltas(y Element, A [][]Element, D [][]Element, C [][]Coefficient) (*Delta, error) {
|
||||||
|
if len(A) != len(D) || len(A) != len(C) {
|
||||||
|
return nil, fmt.Errorf("a, d, c should have same length")
|
||||||
|
}
|
||||||
|
|
||||||
|
one := y.One()
|
||||||
|
size := len(A)
|
||||||
|
|
||||||
|
// dA(x) = ∏ 1..n (yA_i - x)
|
||||||
|
aa := make([]curves.Scalar, 0)
|
||||||
|
// dD(x) = ∏ 1..m (yD_i - x)
|
||||||
|
dd := make([]curves.Scalar, 0)
|
||||||
|
|
||||||
|
a := one
|
||||||
|
d := one
|
||||||
|
|
||||||
|
// dA_{a->b}(y) = ∏ a..b dAs(y)
|
||||||
|
// dD_{a->b}(y) = ∏ a..b dDs(y)
|
||||||
|
for i := 0; i < size; i++ {
|
||||||
|
adds := A[i]
|
||||||
|
dels := D[i]
|
||||||
|
|
||||||
|
// ta = dAs(y)
|
||||||
|
ta, err := dad(adds, y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("dad on additions fails")
|
||||||
|
}
|
||||||
|
// td = dDs(y)
|
||||||
|
td, err := dad(dels, y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("dad on deletions fails")
|
||||||
|
}
|
||||||
|
// ∏ a..b dAs(y)
|
||||||
|
a = a.Mul(ta)
|
||||||
|
// ∏ a..b dDs(y)
|
||||||
|
d = d.Mul(td)
|
||||||
|
|
||||||
|
aa = append(aa, ta)
|
||||||
|
dd = append(dd, td)
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this fails, then this value was removed.
|
||||||
|
d, err := d.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("no inverse exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
// <Gamma_y, Omega>
|
||||||
|
p := make(polynomialPoint, 0, size)
|
||||||
|
|
||||||
|
// Ωi->j+1 = ∑ 1..t (dAt * dDt-1) · Ω
|
||||||
|
for i := 0; i < size; i++ {
|
||||||
|
// t = i+1
|
||||||
|
// ∏^(t-1)_(h=i+1)
|
||||||
|
ddh := one
|
||||||
|
|
||||||
|
// dDi→t−1 (y)
|
||||||
|
for h := 0; h < i; h++ {
|
||||||
|
ddh = ddh.Mul(dd[h])
|
||||||
|
}
|
||||||
|
|
||||||
|
// ∏^(j+1)_(k=t+1)
|
||||||
|
dak := one
|
||||||
|
// dAt->j(y)
|
||||||
|
for k := i + 1; k < size; k++ {
|
||||||
|
dak = dak.Mul(aa[k])
|
||||||
|
}
|
||||||
|
|
||||||
|
// dDi->t-1(y) * dAt->j(y)
|
||||||
|
dak = dak.Mul(ddh)
|
||||||
|
pp := make(polynomialPoint, len(C[i]))
|
||||||
|
for j := 0; j < len(pp); j++ {
|
||||||
|
pp[j] = C[i][j]
|
||||||
|
}
|
||||||
|
|
||||||
|
// dDi->t-1(y) * dAt->j(y) · Ω
|
||||||
|
pp, err := pp.Mul(dak)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("pp.Mul fails")
|
||||||
|
}
|
||||||
|
|
||||||
|
p, err = p.Add(pp)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("pp.Add fails")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// dAi->j(y)/dDi->j(y)
|
||||||
|
a = a.Mul(d)
|
||||||
|
|
||||||
|
// Ωi->j(y)
|
||||||
|
v, err := p.evaluate(y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("p.evaluate fails")
|
||||||
|
}
|
||||||
|
|
||||||
|
// (1/dDi->j(y)) * Ωi->j(y)
|
||||||
|
v = v.Mul(d)
|
||||||
|
|
||||||
|
// return
|
||||||
|
return &Delta{d: a, p: v}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// evaluateDelta computes values used for membership witness batch update
|
||||||
|
// as described in section 4.1 of https://eprint.iacr.org/2020/777.pdf
|
||||||
|
func evaluateDelta(y Element, additions []Element, deletions []Element, coefficients []Coefficient) (*Delta, error) {
|
||||||
|
// dD(y) = ∏ 1..m (yD_i - y), d = 1/dD(y)
|
||||||
|
var err error
|
||||||
|
d, err := dad(deletions, y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("dad fails on deletions")
|
||||||
|
}
|
||||||
|
d, err = d.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("no inverse exists")
|
||||||
|
}
|
||||||
|
|
||||||
|
// dA(y) = ∏ 1..n (yA_i - y)
|
||||||
|
a, err := dad(additions, y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("dad fails on additions")
|
||||||
|
}
|
||||||
|
// dA(y)/dD(y)
|
||||||
|
a = a.Mul(d)
|
||||||
|
|
||||||
|
// Create a PolynomialG1 from coefficients
|
||||||
|
p := make(polynomialPoint, len(coefficients))
|
||||||
|
for i := 0; i < len(coefficients); i++ {
|
||||||
|
p[i] = coefficients[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
// <Gamma_y, Omega>
|
||||||
|
v, err := p.evaluate(y)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("p.evaluate fails")
|
||||||
|
}
|
||||||
|
// 1/dD * <Gamma_y, Omega>
|
||||||
|
v = v.Mul(d)
|
||||||
|
|
||||||
|
return &Delta{d: a, p: v}, nil
|
||||||
|
}
|
||||||
Executable
+229
@@ -0,0 +1,229 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package accumulator
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_Membership_Witness_New(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
var seed [32]byte
|
||||||
|
key, _ := new(SecretKey).New(curve, seed[:])
|
||||||
|
acc, _ := new(Accumulator).New(curve)
|
||||||
|
e := curve.Scalar.New(2)
|
||||||
|
mw, err := new(MembershipWitness).New(e, acc, key)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, mw.c)
|
||||||
|
require.NotNil(t, mw.y)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Membership_Witness_Marshal(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
mw := &MembershipWitness{
|
||||||
|
curve.PointG1.Generator().Mul(curve.Scalar.New(10)),
|
||||||
|
curve.Scalar.New(15),
|
||||||
|
}
|
||||||
|
data, err := mw.MarshalBinary()
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, data)
|
||||||
|
newMW := &MembershipWitness{}
|
||||||
|
err = newMW.UnmarshalBinary(data)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, mw.c.Equal(newMW.c))
|
||||||
|
require.Equal(t, 0, mw.y.Cmp(newMW.y))
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Membership(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk, _ := new(SecretKey).New(curve, []byte("1234567890"))
|
||||||
|
pk, _ := sk.GetPublicKey(curve)
|
||||||
|
|
||||||
|
element1 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
element4 := curve.Scalar.Hash([]byte("6"))
|
||||||
|
element5 := curve.Scalar.Hash([]byte("7"))
|
||||||
|
element6 := curve.Scalar.Hash([]byte("8"))
|
||||||
|
element7 := curve.Scalar.Hash([]byte("9"))
|
||||||
|
elements := []Element{element1, element2, element3, element4, element5, element6, element7}
|
||||||
|
|
||||||
|
// nm_witness_max works as well if set to value larger than 0 for this test.x
|
||||||
|
acc, err := new(Accumulator).WithElements(curve, sk, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc.value)
|
||||||
|
require.False(t, acc.value.IsIdentity())
|
||||||
|
require.True(t, acc.value.IsOnCurve())
|
||||||
|
require.NotEqual(t, acc.value, curve.NewG1GeneratorPoint())
|
||||||
|
|
||||||
|
wit, err := new(MembershipWitness).New(elements[3], acc, sk)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, wit.y, elements[3])
|
||||||
|
|
||||||
|
err = wit.Verify(pk, acc)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Test wrong cases, forge a wrong witness
|
||||||
|
wrongWit := MembershipWitness{
|
||||||
|
curve.PointG1.Identity(),
|
||||||
|
curve.Scalar.One(),
|
||||||
|
}
|
||||||
|
err = wrongWit.Verify(pk, acc)
|
||||||
|
require.Error(t, err)
|
||||||
|
|
||||||
|
// Test wrong cases, forge a wrong accumulator
|
||||||
|
wrongAcc := &Accumulator{
|
||||||
|
curve.PointG1.Generator(),
|
||||||
|
}
|
||||||
|
err = wit.Verify(pk, wrongAcc)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Membership_Batch_Update(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk, _ := new(SecretKey).New(curve, []byte("1234567890"))
|
||||||
|
pk, _ := sk.GetPublicKey(curve)
|
||||||
|
|
||||||
|
element1 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
element4 := curve.Scalar.Hash([]byte("6"))
|
||||||
|
element5 := curve.Scalar.Hash([]byte("7"))
|
||||||
|
element6 := curve.Scalar.Hash([]byte("8"))
|
||||||
|
element7 := curve.Scalar.Hash([]byte("9"))
|
||||||
|
elements := []Element{element1, element2, element3, element4, element5, element6, element7}
|
||||||
|
|
||||||
|
// nm_witness_max works as well if set to value larger than 0 for this test.
|
||||||
|
acc, err := new(Accumulator).WithElements(curve, sk, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc.value)
|
||||||
|
|
||||||
|
wit, err := new(MembershipWitness).New(elements[3], acc, sk)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, wit.y, elements[3])
|
||||||
|
|
||||||
|
err = wit.Verify(pk, acc)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
data1 := curve.Scalar.Hash([]byte("1"))
|
||||||
|
data2 := curve.Scalar.Hash([]byte("2"))
|
||||||
|
data3 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
data4 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
data5 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
data := []Element{data1, data2, data3, data4, data5}
|
||||||
|
additions := data[0:2]
|
||||||
|
deletions := data[2:5]
|
||||||
|
_, coefficients, err := acc.Update(sk, additions, deletions)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, coefficients)
|
||||||
|
|
||||||
|
_, err = wit.BatchUpdate(additions, deletions, coefficients)
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = wit.Verify(pk, acc)
|
||||||
|
require.Nil(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Membership_Multi_Batch_Update(t *testing.T) {
|
||||||
|
curve := curves.BLS12381(&curves.PointBls12381G1{})
|
||||||
|
sk, _ := new(SecretKey).New(curve, []byte("1234567890"))
|
||||||
|
pk, _ := sk.GetPublicKey(curve)
|
||||||
|
|
||||||
|
element1 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
element2 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
element3 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
element4 := curve.Scalar.Hash([]byte("6"))
|
||||||
|
element5 := curve.Scalar.Hash([]byte("7"))
|
||||||
|
element6 := curve.Scalar.Hash([]byte("8"))
|
||||||
|
element7 := curve.Scalar.Hash([]byte("9"))
|
||||||
|
element8 := curve.Scalar.Hash([]byte("10"))
|
||||||
|
element9 := curve.Scalar.Hash([]byte("11"))
|
||||||
|
element10 := curve.Scalar.Hash([]byte("12"))
|
||||||
|
element11 := curve.Scalar.Hash([]byte("13"))
|
||||||
|
element12 := curve.Scalar.Hash([]byte("14"))
|
||||||
|
element13 := curve.Scalar.Hash([]byte("15"))
|
||||||
|
element14 := curve.Scalar.Hash([]byte("16"))
|
||||||
|
element15 := curve.Scalar.Hash([]byte("17"))
|
||||||
|
element16 := curve.Scalar.Hash([]byte("18"))
|
||||||
|
element17 := curve.Scalar.Hash([]byte("19"))
|
||||||
|
element18 := curve.Scalar.Hash([]byte("20"))
|
||||||
|
elements := []Element{
|
||||||
|
element1,
|
||||||
|
element2,
|
||||||
|
element3,
|
||||||
|
element4,
|
||||||
|
element5,
|
||||||
|
element6,
|
||||||
|
element7,
|
||||||
|
element8,
|
||||||
|
element9,
|
||||||
|
element10,
|
||||||
|
element11,
|
||||||
|
element12,
|
||||||
|
element13,
|
||||||
|
element14,
|
||||||
|
element15,
|
||||||
|
element16,
|
||||||
|
element17,
|
||||||
|
element18,
|
||||||
|
}
|
||||||
|
acc, err := new(Accumulator).WithElements(curve, sk, elements)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, acc.value)
|
||||||
|
|
||||||
|
wit, err := new(MembershipWitness).New(elements[3], acc, sk)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = wit.Verify(pk, acc)
|
||||||
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
data1 := curve.Scalar.Hash([]byte("1"))
|
||||||
|
data2 := curve.Scalar.Hash([]byte("2"))
|
||||||
|
data3 := curve.Scalar.Hash([]byte("3"))
|
||||||
|
data4 := curve.Scalar.Hash([]byte("4"))
|
||||||
|
data5 := curve.Scalar.Hash([]byte("5"))
|
||||||
|
data := []Element{data1, data2, data3, data4, data5}
|
||||||
|
adds1 := data[0:2]
|
||||||
|
dels1 := data[2:5]
|
||||||
|
_, coeffs1, err := acc.Update(sk, adds1, dels1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, coeffs1)
|
||||||
|
|
||||||
|
dels2 := elements[8:10]
|
||||||
|
_, coeffs2, err := acc.Update(sk, []Element{}, dels2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, coeffs2)
|
||||||
|
|
||||||
|
dels3 := elements[11:14]
|
||||||
|
_, coeffs3, err := acc.Update(sk, []Element{}, dels3)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, coeffs3)
|
||||||
|
|
||||||
|
a := make([][]Element, 3)
|
||||||
|
a[0] = adds1
|
||||||
|
a[1] = []Element{}
|
||||||
|
a[2] = []Element{}
|
||||||
|
|
||||||
|
d := make([][]Element, 3)
|
||||||
|
d[0] = dels1
|
||||||
|
d[1] = dels2
|
||||||
|
d[2] = dels3
|
||||||
|
|
||||||
|
c := make([][]Coefficient, 3)
|
||||||
|
c[0] = coeffs1
|
||||||
|
c[1] = coeffs2
|
||||||
|
c[2] = coeffs3
|
||||||
|
|
||||||
|
_, err = wit.MultiBatchUpdate(a, d, c)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
err = wit.Verify(pk, acc)
|
||||||
|
require.Nil(t, err)
|
||||||
|
}
|
||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
"golang.org/x/crypto/sha3"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// generators contains a list of points to be used as generators for bulletproofs.
|
||||||
|
type generators []curves.Point
|
||||||
|
|
||||||
|
// ippGenerators holds generators necessary for an Inner Product Proof
|
||||||
|
// It includes a single u generator, and a list of generators divided in half to G and H
|
||||||
|
// See lines 10 on pg 16 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
type ippGenerators struct {
|
||||||
|
G generators
|
||||||
|
H generators
|
||||||
|
}
|
||||||
|
|
||||||
|
// getGeneratorPoints generates generators using HashToCurve with Shake256(domain) as input
|
||||||
|
// lenVector is the length of the scalars used for the Inner Product Proof
|
||||||
|
// getGeneratorPoints will return 2*lenVector + 1 total points, split between a single u generator
|
||||||
|
// and G and H lists of vectors per the IPP specification
|
||||||
|
// See lines 10 on pg 16 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func getGeneratorPoints(lenVector int, domain []byte, curve curves.Curve) (*ippGenerators, error) {
|
||||||
|
shake := sha3.NewShake256()
|
||||||
|
_, err := shake.Write(domain)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "getGeneratorPoints shake.Write")
|
||||||
|
}
|
||||||
|
numPoints := lenVector * 2
|
||||||
|
points := make([]curves.Point, numPoints)
|
||||||
|
for i := 0; i < numPoints; i++ {
|
||||||
|
bytes := [64]byte{}
|
||||||
|
_, err := shake.Read(bytes[:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "getGeneratorPoints shake.Read")
|
||||||
|
}
|
||||||
|
nextPoint := curve.Point.Hash(bytes[:])
|
||||||
|
points[i] = nextPoint
|
||||||
|
}
|
||||||
|
// Get G and H by splitting points in half
|
||||||
|
G, H, err := splitPointVector(points)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "getGeneratorPoints splitPointVector")
|
||||||
|
}
|
||||||
|
out := ippGenerators{G: G, H: H}
|
||||||
|
|
||||||
|
return &out, nil
|
||||||
|
}
|
||||||
Executable
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
"golang.org/x/crypto/sha3"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGeneratorsHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
gs, err := getGeneratorPoints(10, []byte("test"), *curve)
|
||||||
|
gsConcatenated := concatIPPGenerators(*gs)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, gs.G, 10)
|
||||||
|
require.Len(t, gs.H, 10)
|
||||||
|
require.True(t, noDuplicates(gsConcatenated))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGeneratorsUniquePerDomain(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
gs1, err := getGeneratorPoints(10, []byte("test"), *curve)
|
||||||
|
gs1Concatenated := concatIPPGenerators(*gs1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
gs2, err := getGeneratorPoints(10, []byte("test2"), *curve)
|
||||||
|
gs2Concatenated := concatIPPGenerators(*gs2)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, areDisjoint(gs1Concatenated, gs2Concatenated))
|
||||||
|
}
|
||||||
|
|
||||||
|
func noDuplicates(gs generators) bool {
|
||||||
|
seen := map[[32]byte]bool{}
|
||||||
|
for _, G := range gs {
|
||||||
|
value := sha3.Sum256(G.ToAffineCompressed())
|
||||||
|
if seen[value] {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
seen[value] = true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func areDisjoint(gs1, gs2 generators) bool {
|
||||||
|
for _, g1 := range gs1 {
|
||||||
|
for _, g2 := range gs2 {
|
||||||
|
if g1.Equal(g2) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func concatIPPGenerators(ippGens ippGenerators) generators {
|
||||||
|
var out generators
|
||||||
|
out = append(out, ippGens.G...)
|
||||||
|
out = append(out, ippGens.H...)
|
||||||
|
return out
|
||||||
|
}
|
||||||
Executable
+181
@@ -0,0 +1,181 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// innerProduct takes two lists of scalars (a, b) and performs the dot product returning a single scalar.
|
||||||
|
func innerProduct(a, b []curves.Scalar) (curves.Scalar, error) {
|
||||||
|
if len(a) != len(b) {
|
||||||
|
return nil, errors.New("length of scalar vectors must be the same")
|
||||||
|
}
|
||||||
|
if len(a) < 1 {
|
||||||
|
return nil, errors.New("length of vectors must be at least one")
|
||||||
|
}
|
||||||
|
// Get a new scalar of value zero of the same curve as input arguments
|
||||||
|
innerProduct := a[0].Zero()
|
||||||
|
for i, aElem := range a {
|
||||||
|
bElem := b[i]
|
||||||
|
// innerProduct = aElem*bElem + innerProduct
|
||||||
|
innerProduct = aElem.MulAdd(bElem, innerProduct)
|
||||||
|
}
|
||||||
|
|
||||||
|
return innerProduct, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// splitPointVector takes a vector of points, splits it in half returning each half.
|
||||||
|
func splitPointVector(points []curves.Point) ([]curves.Point, []curves.Point, error) {
|
||||||
|
if len(points) < 1 {
|
||||||
|
return nil, nil, errors.New("length of points must be at least one")
|
||||||
|
}
|
||||||
|
if len(points)&0x01 != 0 {
|
||||||
|
return nil, nil, errors.New("length of points must be even")
|
||||||
|
}
|
||||||
|
nPrime := len(points) >> 1
|
||||||
|
firstHalf := points[:nPrime]
|
||||||
|
secondHalf := points[nPrime:]
|
||||||
|
return firstHalf, secondHalf, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// splitScalarVector takes a vector of scalars, splits it in half returning each half.
|
||||||
|
func splitScalarVector(scalars []curves.Scalar) ([]curves.Scalar, []curves.Scalar, error) {
|
||||||
|
if len(scalars) < 1 {
|
||||||
|
return nil, nil, errors.New("length of scalars must be at least one")
|
||||||
|
}
|
||||||
|
if len(scalars)&0x01 != 0 {
|
||||||
|
return nil, nil, errors.New("length of scalars must be even")
|
||||||
|
}
|
||||||
|
nPrime := len(scalars) >> 1
|
||||||
|
firstHalf := scalars[:nPrime]
|
||||||
|
secondHalf := scalars[nPrime:]
|
||||||
|
return firstHalf, secondHalf, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// multiplyScalarToPointVector takes a single scalar and a list of points, multiplies each point by scalar.
|
||||||
|
func multiplyScalarToPointVector(x curves.Scalar, g []curves.Point) []curves.Point {
|
||||||
|
products := make([]curves.Point, len(g))
|
||||||
|
for i, gElem := range g {
|
||||||
|
product := gElem.Mul(x)
|
||||||
|
products[i] = product
|
||||||
|
}
|
||||||
|
|
||||||
|
return products
|
||||||
|
}
|
||||||
|
|
||||||
|
// multiplyScalarToScalarVector takes a single scalar (x) and a list of scalars (a), multiplies each scalar in the vector by the scalar.
|
||||||
|
func multiplyScalarToScalarVector(x curves.Scalar, a []curves.Scalar) []curves.Scalar {
|
||||||
|
products := make([]curves.Scalar, len(a))
|
||||||
|
for i, aElem := range a {
|
||||||
|
product := aElem.Mul(x)
|
||||||
|
products[i] = product
|
||||||
|
}
|
||||||
|
|
||||||
|
return products
|
||||||
|
}
|
||||||
|
|
||||||
|
// multiplyPairwisePointVectors takes two lists of points (g, h) and performs a pairwise multiplication returning a list of points.
|
||||||
|
func multiplyPairwisePointVectors(g, h []curves.Point) ([]curves.Point, error) {
|
||||||
|
if len(g) != len(h) {
|
||||||
|
return nil, errors.New("length of point vectors must be the same")
|
||||||
|
}
|
||||||
|
product := make([]curves.Point, len(g))
|
||||||
|
for i, gElem := range g {
|
||||||
|
product[i] = gElem.Add(h[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return product, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// multiplyPairwiseScalarVectors takes two lists of points (a, b) and performs a pairwise multiplication returning a list of scalars.
|
||||||
|
func multiplyPairwiseScalarVectors(a, b []curves.Scalar) ([]curves.Scalar, error) {
|
||||||
|
if len(a) != len(b) {
|
||||||
|
return nil, errors.New("length of point vectors must be the same")
|
||||||
|
}
|
||||||
|
product := make([]curves.Scalar, len(a))
|
||||||
|
for i, aElem := range a {
|
||||||
|
product[i] = aElem.Mul(b[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return product, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// addPairwiseScalarVectors takes two lists of scalars (a, b) and performs a pairwise addition returning a list of scalars.
|
||||||
|
func addPairwiseScalarVectors(a, b []curves.Scalar) ([]curves.Scalar, error) {
|
||||||
|
if len(a) != len(b) {
|
||||||
|
return nil, errors.New("length of scalar vectors must be the same")
|
||||||
|
}
|
||||||
|
sum := make([]curves.Scalar, len(a))
|
||||||
|
for i, aElem := range a {
|
||||||
|
sum[i] = aElem.Add(b[i])
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// subtractPairwiseScalarVectors takes two lists of scalars (a, b) and performs a pairwise subtraction returning a list of scalars.
|
||||||
|
func subtractPairwiseScalarVectors(a, b []curves.Scalar) ([]curves.Scalar, error) {
|
||||||
|
if len(a) != len(b) {
|
||||||
|
return nil, errors.New("length of scalar vectors must be the same")
|
||||||
|
}
|
||||||
|
diff := make([]curves.Scalar, len(a))
|
||||||
|
for i, aElem := range a {
|
||||||
|
diff[i] = aElem.Sub(b[i])
|
||||||
|
}
|
||||||
|
return diff, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// invertScalars takes a list of scalars then returns a list with each element inverted.
|
||||||
|
func invertScalars(xs []curves.Scalar) ([]curves.Scalar, error) {
|
||||||
|
xinvs := make([]curves.Scalar, len(xs))
|
||||||
|
for i, x := range xs {
|
||||||
|
xinv, err := x.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "bulletproof helpers invertx")
|
||||||
|
}
|
||||||
|
xinvs[i] = xinv
|
||||||
|
}
|
||||||
|
|
||||||
|
return xinvs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// isPowerOfTwo returns whether a number i is a power of two or not.
|
||||||
|
func isPowerOfTwo(i int) bool {
|
||||||
|
return i&(i-1) == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// get2nVector returns a scalar vector 2^n such that [1, 2, 4, ... 2^(n-1)]
|
||||||
|
// See k^n and 2^n definitions on pg 12 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func get2nVector(length int, curve curves.Curve) []curves.Scalar {
|
||||||
|
vector2n := make([]curves.Scalar, length)
|
||||||
|
vector2n[0] = curve.Scalar.One()
|
||||||
|
for i := 1; i < length; i++ {
|
||||||
|
vector2n[i] = vector2n[i-1].Double()
|
||||||
|
}
|
||||||
|
return vector2n
|
||||||
|
}
|
||||||
|
|
||||||
|
func get1nVector(length int, curve curves.Curve) []curves.Scalar {
|
||||||
|
vector1n := make([]curves.Scalar, length)
|
||||||
|
for i := 0; i < length; i++ {
|
||||||
|
vector1n[i] = curve.Scalar.One()
|
||||||
|
}
|
||||||
|
return vector1n
|
||||||
|
}
|
||||||
|
|
||||||
|
func getknVector(k curves.Scalar, length int, curve curves.Curve) []curves.Scalar {
|
||||||
|
vectorkn := make([]curves.Scalar, length)
|
||||||
|
vectorkn[0] = curve.Scalar.One()
|
||||||
|
vectorkn[1] = k
|
||||||
|
for i := 2; i < length; i++ {
|
||||||
|
vectorkn[i] = vectorkn[i-1].Mul(k)
|
||||||
|
}
|
||||||
|
return vectorkn
|
||||||
|
}
|
||||||
Executable
+85
@@ -0,0 +1,85 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInnerProductHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
a := randScalarVec(3, *curve)
|
||||||
|
b := randScalarVec(3, *curve)
|
||||||
|
_, err := innerProduct(a, b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInnerProductMismatchedLengths(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
a := randScalarVec(3, *curve)
|
||||||
|
b := randScalarVec(4, *curve)
|
||||||
|
_, err := innerProduct(a, b)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInnerProductEmptyVector(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
a := randScalarVec(0, *curve)
|
||||||
|
b := randScalarVec(0, *curve)
|
||||||
|
_, err := innerProduct(a, b)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestInnerProductOut(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
a := randScalarVec(2, *curve)
|
||||||
|
b := randScalarVec(2, *curve)
|
||||||
|
c, err := innerProduct(a, b)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Calculate manually a0*b0 + a1*b1
|
||||||
|
cPrime := a[0].Mul(b[0]).Add(a[1].Mul(b[1]))
|
||||||
|
require.Equal(t, c, cPrime)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSplitListofPointsHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
points := randPointVec(10, *curve)
|
||||||
|
firstHalf, secondHalf, err := splitPointVector(points)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Len(t, firstHalf, 5)
|
||||||
|
require.Len(t, secondHalf, 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSplitListofPointsOddLength(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
points := randPointVec(11, *curve)
|
||||||
|
_, _, err := splitPointVector(points)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestSplitListofPointsZeroLength(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
points := randPointVec(0, *curve)
|
||||||
|
_, _, err := splitPointVector(points)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func randScalarVec(length int, curve curves.Curve) []curves.Scalar {
|
||||||
|
out := make([]curves.Scalar, length)
|
||||||
|
for i := 0; i < length; i++ {
|
||||||
|
out[i] = curve.Scalar.Random(crand.Reader)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func randPointVec(length int, curve curves.Curve) []curves.Point {
|
||||||
|
out := make([]curves.Point, length)
|
||||||
|
for i := 0; i < length; i++ {
|
||||||
|
out[i] = curve.Point.Random(crand.Reader)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
Executable
+396
@@ -0,0 +1,396 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package bulletproof implements the zero knowledge protocol bulletproofs as defined in https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InnerProductProver is the struct used to create InnerProductProofs
|
||||||
|
// It specifies which curve to use and holds precomputed generators
|
||||||
|
// See NewInnerProductProver() for prover initialization.
|
||||||
|
type InnerProductProver struct {
|
||||||
|
curve curves.Curve
|
||||||
|
generators ippGenerators
|
||||||
|
}
|
||||||
|
|
||||||
|
// InnerProductProof contains necessary output for the inner product proof
|
||||||
|
// a and b are the final input vectors of scalars, they should be of length 1
|
||||||
|
// Ls and Rs are calculated per recursion of the IPP and are necessary for verification
|
||||||
|
// See section 3.1 on pg 15 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
type InnerProductProof struct {
|
||||||
|
a, b curves.Scalar
|
||||||
|
capLs, capRs []curves.Point
|
||||||
|
curve *curves.Curve
|
||||||
|
}
|
||||||
|
|
||||||
|
// ippRecursion is the same as IPP but tracks recursive a', b', g', h' and Ls and Rs
|
||||||
|
// It should only be used internally by InnerProductProver.Prove()
|
||||||
|
// See L35 on pg 16 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
type ippRecursion struct {
|
||||||
|
a, b []curves.Scalar
|
||||||
|
c curves.Scalar
|
||||||
|
capLs, capRs []curves.Point
|
||||||
|
g, h []curves.Point
|
||||||
|
u, capP curves.Point
|
||||||
|
transcript *merlin.Transcript
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInnerProductProver initializes a new prover
|
||||||
|
// It uses the specified domain to generate generators for vectors of at most maxVectorLength
|
||||||
|
// A prover can be used to construct inner product proofs for vectors of length less than or equal to maxVectorLength
|
||||||
|
// A prover is defined by an explicit curve.
|
||||||
|
func NewInnerProductProver(maxVectorLength int, domain []byte, curve curves.Curve) (*InnerProductProver, error) {
|
||||||
|
generators, err := getGeneratorPoints(maxVectorLength, domain, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "ipp getGenerators")
|
||||||
|
}
|
||||||
|
return &InnerProductProver{curve: curve, generators: *generators}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInnerProductProof initializes a new InnerProductProof for a specified curve
|
||||||
|
// This should be used in tandem with UnmarshalBinary() to convert a marshaled proof into the struct.
|
||||||
|
func NewInnerProductProof(curve *curves.Curve) *InnerProductProof {
|
||||||
|
var capLs, capRs []curves.Point
|
||||||
|
newProof := InnerProductProof{
|
||||||
|
a: curve.NewScalar(),
|
||||||
|
b: curve.NewScalar(),
|
||||||
|
capLs: capLs,
|
||||||
|
capRs: capRs,
|
||||||
|
curve: curve,
|
||||||
|
}
|
||||||
|
return &newProof
|
||||||
|
}
|
||||||
|
|
||||||
|
// rangeToIPP takes the output of a range proof and converts it into an inner product proof
|
||||||
|
// See section 4.2 on pg 20
|
||||||
|
// The conversion specifies generators to use (g and hPrime), as well as the two vectors l, r of which the inner product is tHat
|
||||||
|
// Additionally, note that the P used for the IPP is in fact P*h^-mu from the range proof.
|
||||||
|
func (prover *InnerProductProver) rangeToIPP(proofG, proofH []curves.Point, l, r []curves.Scalar, tHat curves.Scalar, capPhmuinv, u curves.Point, transcript *merlin.Transcript) (*InnerProductProof, error) {
|
||||||
|
// Note that P as a witness is only g^l * h^r
|
||||||
|
// P needs to be in the form of g^l * h^r * u^<l,r>
|
||||||
|
// Calculate the final P including the u^<l,r> term
|
||||||
|
utHat := u.Mul(tHat)
|
||||||
|
capP := capPhmuinv.Add(utHat)
|
||||||
|
|
||||||
|
// Use params to prove inner product
|
||||||
|
recursionParams := &ippRecursion{
|
||||||
|
a: l,
|
||||||
|
b: r,
|
||||||
|
capLs: []curves.Point{},
|
||||||
|
capRs: []curves.Point{},
|
||||||
|
c: tHat,
|
||||||
|
g: proofG,
|
||||||
|
h: proofH,
|
||||||
|
capP: capP,
|
||||||
|
u: u,
|
||||||
|
transcript: transcript,
|
||||||
|
}
|
||||||
|
|
||||||
|
return prover.proveRecursive(recursionParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
// getP returns the initial P value given two scalars a,b and point u
|
||||||
|
// This method should only be used for testing
|
||||||
|
// See (3) on page 13 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func (prover *InnerProductProver) getP(a, b []curves.Scalar, u curves.Point) (curves.Point, error) {
|
||||||
|
// Vectors must have length power of two
|
||||||
|
if !isPowerOfTwo(len(a)) {
|
||||||
|
return nil, errors.New("ipp vector length must be power of two")
|
||||||
|
}
|
||||||
|
// Generator vectors must be same length
|
||||||
|
if len(prover.generators.G) != len(prover.generators.H) {
|
||||||
|
return nil, errors.New("ipp generator lengths of g and h must be equal")
|
||||||
|
}
|
||||||
|
// Inner product requires len(a) == len(b) else error is returned
|
||||||
|
c, err := innerProduct(a, b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "ipp getInnerProduct")
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case where len(a) is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := prover.generators.G[0:len(a)]
|
||||||
|
proofH := prover.generators.H[0:len(b)]
|
||||||
|
|
||||||
|
// initial P = g^a * h^b * u^(a dot b) (See (3) on page 13 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
ga := prover.curve.NewGeneratorPoint().SumOfProducts(proofG, a)
|
||||||
|
hb := prover.curve.NewGeneratorPoint().SumOfProducts(proofH, b)
|
||||||
|
uadotb := u.Mul(c)
|
||||||
|
capP := ga.Add(hb).Add(uadotb)
|
||||||
|
|
||||||
|
return capP, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prove executes the prover protocol on pg 16 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
// It generates an inner product proof for vectors a and b, using u to blind the inner product in P
|
||||||
|
// A transcript is used for the Fiat Shamir heuristic.
|
||||||
|
func (prover *InnerProductProver) Prove(a, b []curves.Scalar, u curves.Point, transcript *merlin.Transcript) (*InnerProductProof, error) {
|
||||||
|
// Vectors must have length power of two
|
||||||
|
if !isPowerOfTwo(len(a)) {
|
||||||
|
return nil, errors.New("ipp vector length must be power of two")
|
||||||
|
}
|
||||||
|
// Generator vectors must be same length
|
||||||
|
if len(prover.generators.G) != len(prover.generators.H) {
|
||||||
|
return nil, errors.New("ipp generator lengths of g and h must be equal")
|
||||||
|
}
|
||||||
|
// Inner product requires len(a) == len(b) else error is returned
|
||||||
|
c, err := innerProduct(a, b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "ipp getInnerProduct")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Length of vectors must be less than the number of generators generated
|
||||||
|
if len(a) > len(prover.generators.G) {
|
||||||
|
return nil, errors.New("ipp vector length must be less than maxVectorLength")
|
||||||
|
}
|
||||||
|
// In case where len(a) is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := prover.generators.G[0:len(a)]
|
||||||
|
proofH := prover.generators.H[0:len(b)]
|
||||||
|
|
||||||
|
// initial P = g^a * h^b * u^(a dot b) (See (3) on page 13 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
ga := prover.curve.NewGeneratorPoint().SumOfProducts(proofG, a)
|
||||||
|
hb := prover.curve.NewGeneratorPoint().SumOfProducts(proofH, b)
|
||||||
|
uadotb := u.Mul(c)
|
||||||
|
capP := ga.Add(hb).Add(uadotb)
|
||||||
|
|
||||||
|
recursionParams := &ippRecursion{
|
||||||
|
a: a,
|
||||||
|
b: b,
|
||||||
|
capLs: []curves.Point{},
|
||||||
|
capRs: []curves.Point{},
|
||||||
|
c: c,
|
||||||
|
g: proofG,
|
||||||
|
h: proofH,
|
||||||
|
capP: capP,
|
||||||
|
u: u,
|
||||||
|
transcript: transcript,
|
||||||
|
}
|
||||||
|
return prover.proveRecursive(recursionParams)
|
||||||
|
}
|
||||||
|
|
||||||
|
// proveRecursive executes the recursion on pg 16 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func (prover *InnerProductProver) proveRecursive(recursionParams *ippRecursion) (*InnerProductProof, error) {
|
||||||
|
// length checks
|
||||||
|
if len(recursionParams.a) != len(recursionParams.b) {
|
||||||
|
return nil, errors.New("ipp proveRecursive a and b different lengths")
|
||||||
|
}
|
||||||
|
if len(recursionParams.g) != len(recursionParams.h) {
|
||||||
|
return nil, errors.New("ipp proveRecursive g and h different lengths")
|
||||||
|
}
|
||||||
|
if len(recursionParams.a) != len(recursionParams.g) {
|
||||||
|
return nil, errors.New("ipp proveRecursive scalar and point vectors different lengths")
|
||||||
|
}
|
||||||
|
// Base case (L14, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
if len(recursionParams.a) == 1 {
|
||||||
|
proof := &InnerProductProof{
|
||||||
|
a: recursionParams.a[0],
|
||||||
|
b: recursionParams.b[0],
|
||||||
|
capLs: recursionParams.capLs,
|
||||||
|
capRs: recursionParams.capRs,
|
||||||
|
curve: &prover.curve,
|
||||||
|
}
|
||||||
|
return proof, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split current state into low (first half) vs high (second half) vectors
|
||||||
|
aLo, aHi, err := splitScalarVector(recursionParams.a)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams splitScalarVector")
|
||||||
|
}
|
||||||
|
bLo, bHi, err := splitScalarVector(recursionParams.b)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams splitScalarVector")
|
||||||
|
}
|
||||||
|
gLo, gHi, err := splitPointVector(recursionParams.g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams splitPointVector")
|
||||||
|
}
|
||||||
|
hLo, hHi, err := splitPointVector(recursionParams.h)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams splitPointVector")
|
||||||
|
}
|
||||||
|
|
||||||
|
// c_l, c_r (L21,22, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
cL, err := innerProduct(aLo, bHi)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams innerProduct")
|
||||||
|
}
|
||||||
|
|
||||||
|
cR, err := innerProduct(aHi, bLo)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams innerProduct")
|
||||||
|
}
|
||||||
|
|
||||||
|
// L, R (L23,24, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
lga := prover.curve.Point.SumOfProducts(gHi, aLo)
|
||||||
|
lhb := prover.curve.Point.SumOfProducts(hLo, bHi)
|
||||||
|
ucL := recursionParams.u.Mul(cL)
|
||||||
|
capL := lga.Add(lhb).Add(ucL)
|
||||||
|
|
||||||
|
rga := prover.curve.Point.SumOfProducts(gLo, aHi)
|
||||||
|
rhb := prover.curve.Point.SumOfProducts(hHi, bLo)
|
||||||
|
ucR := recursionParams.u.Mul(cR)
|
||||||
|
capR := rga.Add(rhb).Add(ucR)
|
||||||
|
|
||||||
|
// Add L,R for verifier to use to calculate final g, h
|
||||||
|
newL := recursionParams.capLs
|
||||||
|
newL = append(newL, capL)
|
||||||
|
newR := recursionParams.capRs
|
||||||
|
newR = append(newR, capR)
|
||||||
|
|
||||||
|
// Get x from L, R for non-interactive (See section 4.4 pg22 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
// Note this replaces the interactive model, i.e. L36-28 of pg16 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
x, err := prover.calcx(capL, capR, recursionParams.transcript)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams calcx")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate recursive inputs
|
||||||
|
xInv, err := x.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams x.Invert")
|
||||||
|
}
|
||||||
|
|
||||||
|
// g', h' (L29,30, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
gLoxInverse := multiplyScalarToPointVector(xInv, gLo)
|
||||||
|
gHix := multiplyScalarToPointVector(x, gHi)
|
||||||
|
gPrime, err := multiplyPairwisePointVectors(gLoxInverse, gHix)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams multiplyPairwisePointVectors")
|
||||||
|
}
|
||||||
|
|
||||||
|
hLox := multiplyScalarToPointVector(x, hLo)
|
||||||
|
hHixInv := multiplyScalarToPointVector(xInv, hHi)
|
||||||
|
hPrime, err := multiplyPairwisePointVectors(hLox, hHixInv)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams multiplyPairwisePointVectors")
|
||||||
|
}
|
||||||
|
|
||||||
|
// P' (L31, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
xSquare := x.Square()
|
||||||
|
xInvSquare := xInv.Square()
|
||||||
|
LxSquare := capL.Mul(xSquare)
|
||||||
|
RxInvSquare := capR.Mul(xInvSquare)
|
||||||
|
PPrime := LxSquare.Add(recursionParams.capP).Add(RxInvSquare)
|
||||||
|
|
||||||
|
// a', b' (L33, 34, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
aLox := multiplyScalarToScalarVector(x, aLo)
|
||||||
|
aHixIn := multiplyScalarToScalarVector(xInv, aHi)
|
||||||
|
aPrime, err := addPairwiseScalarVectors(aLox, aHixIn)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams addPairwiseScalarVectors")
|
||||||
|
}
|
||||||
|
|
||||||
|
bLoxInv := multiplyScalarToScalarVector(xInv, bLo)
|
||||||
|
bHix := multiplyScalarToScalarVector(x, bHi)
|
||||||
|
bPrime, err := addPairwiseScalarVectors(bLoxInv, bHix)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams addPairwiseScalarVectors")
|
||||||
|
}
|
||||||
|
|
||||||
|
// c'
|
||||||
|
cPrime, err := innerProduct(aPrime, bPrime)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams innerProduct")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make recursive call (L35, pg16 of https://eprint.iacr.org/2017/1066.pdf)
|
||||||
|
recursiveIPP := &ippRecursion{
|
||||||
|
a: aPrime,
|
||||||
|
b: bPrime,
|
||||||
|
capLs: newL,
|
||||||
|
capRs: newR,
|
||||||
|
c: cPrime,
|
||||||
|
g: gPrime,
|
||||||
|
h: hPrime,
|
||||||
|
capP: PPrime,
|
||||||
|
u: recursionParams.u,
|
||||||
|
transcript: recursionParams.transcript,
|
||||||
|
}
|
||||||
|
|
||||||
|
out, err := prover.proveRecursive(recursiveIPP)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "recursionParams proveRecursive")
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// calcx uses a merlin transcript for Fiat Shamir
|
||||||
|
// For each recursion, it takes the current state of the transcript and appends the newly calculated L and R values
|
||||||
|
// A new scalar is then read from the transcript
|
||||||
|
// See section 4.4 pg22 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func (prover *InnerProductProver) calcx(capL, capR curves.Point, transcript *merlin.Transcript) (curves.Scalar, error) {
|
||||||
|
// Add the newest capL and capR values to transcript
|
||||||
|
transcript.AppendMessage([]byte("addRecursiveL"), capL.ToAffineUncompressed())
|
||||||
|
transcript.AppendMessage([]byte("addRecursiveR"), capR.ToAffineUncompressed())
|
||||||
|
// Read 64 bytes from, set to scalar
|
||||||
|
outBytes := transcript.ExtractBytes([]byte("getx"), 64)
|
||||||
|
x, err := prover.curve.NewScalar().SetBytesWide(outBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "calcx NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary takes an inner product proof and marshals into bytes.
|
||||||
|
func (proof *InnerProductProof) MarshalBinary() []byte {
|
||||||
|
var out []byte
|
||||||
|
out = append(out, proof.a.Bytes()...)
|
||||||
|
out = append(out, proof.b.Bytes()...)
|
||||||
|
for i, capLElem := range proof.capLs {
|
||||||
|
capRElem := proof.capRs[i]
|
||||||
|
out = append(out, capLElem.ToAffineCompressed()...)
|
||||||
|
out = append(out, capRElem.ToAffineCompressed()...)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary takes bytes of a marshaled proof and writes them into an inner product proof
|
||||||
|
// The inner product proof used should be from the output of NewInnerProductProof().
|
||||||
|
func (proof *InnerProductProof) UnmarshalBinary(data []byte) error {
|
||||||
|
scalarLen := len(proof.curve.NewScalar().Bytes())
|
||||||
|
pointLen := len(proof.curve.NewGeneratorPoint().ToAffineCompressed())
|
||||||
|
ptr := 0
|
||||||
|
// Get scalars
|
||||||
|
a, err := proof.curve.NewScalar().SetBytes(data[ptr : ptr+scalarLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("innerProductProof UnmarshalBinary SetBytes")
|
||||||
|
}
|
||||||
|
proof.a = a
|
||||||
|
ptr += scalarLen
|
||||||
|
b, err := proof.curve.NewScalar().SetBytes(data[ptr : ptr+scalarLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("innerProductProof UnmarshalBinary SetBytes")
|
||||||
|
}
|
||||||
|
proof.b = b
|
||||||
|
ptr += scalarLen
|
||||||
|
// Get points
|
||||||
|
var capLs, capRs []curves.Point //nolint:prealloc // pointer arithmetic makes it too unreadable.
|
||||||
|
for ptr < len(data) {
|
||||||
|
capLElem, err := proof.curve.Point.FromAffineCompressed(data[ptr : ptr+pointLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("innerProductProof UnmarshalBinary FromAffineCompressed")
|
||||||
|
}
|
||||||
|
capLs = append(capLs, capLElem)
|
||||||
|
ptr += pointLen
|
||||||
|
capRElem, err := proof.curve.Point.FromAffineCompressed(data[ptr : ptr+pointLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("innerProductProof UnmarshalBinary FromAffineCompressed")
|
||||||
|
}
|
||||||
|
capRs = append(capRs, capRElem)
|
||||||
|
ptr += pointLen
|
||||||
|
}
|
||||||
|
proof.capLs = capLs
|
||||||
|
proof.capRs = capRs
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Executable
+99
@@ -0,0 +1,99 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIPPHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
prover, err := NewInnerProductProver(8, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(8, *curve)
|
||||||
|
b := randScalarVec(8, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(a, b, u, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Equal(t, 3, len(proof.capLs))
|
||||||
|
require.Equal(t, 3, len(proof.capRs))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPPMismatchedVectors(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
prover, err := NewInnerProductProver(8, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(4, *curve)
|
||||||
|
b := randScalarVec(8, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
_, err = prover.Prove(a, b, u, transcript)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPPNonPowerOfTwoLengthVectors(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
prover, err := NewInnerProductProver(8, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(3, *curve)
|
||||||
|
b := randScalarVec(3, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
_, err = prover.Prove(a, b, u, transcript)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPPZeroLengthVectors(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
prover, err := NewInnerProductProver(8, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(0, *curve)
|
||||||
|
b := randScalarVec(0, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
_, err = prover.Prove(a, b, u, transcript)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPPGreaterThanMaxLengthVectors(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
prover, err := NewInnerProductProver(8, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(16, *curve)
|
||||||
|
b := randScalarVec(16, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
_, err = prover.Prove(a, b, u, transcript)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPPMarshal(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
prover, err := NewInnerProductProver(8, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(8, *curve)
|
||||||
|
b := randScalarVec(8, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(a, b, u, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
proofMarshaled := proof.MarshalBinary()
|
||||||
|
proofPrime := NewInnerProductProof(curve)
|
||||||
|
err = proofPrime.UnmarshalBinary(proofMarshaled)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, proof.a.Cmp(proofPrime.a))
|
||||||
|
require.Zero(t, proof.b.Cmp(proofPrime.b))
|
||||||
|
for i, proofCapLElem := range proof.capLs {
|
||||||
|
proofPrimeCapLElem := proofPrime.capLs[i]
|
||||||
|
require.True(t, proofCapLElem.Equal(proofPrimeCapLElem))
|
||||||
|
proofCapRElem := proof.capRs[i]
|
||||||
|
proofPrimeCapRElem := proofPrime.capRs[i]
|
||||||
|
require.True(t, proofCapRElem.Equal(proofPrimeCapRElem))
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+209
@@ -0,0 +1,209 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InnerProductVerifier is the struct used to verify inner product proofs
|
||||||
|
// It specifies which curve to use and holds precomputed generators
|
||||||
|
// See NewInnerProductProver() for prover initialization.
|
||||||
|
type InnerProductVerifier struct {
|
||||||
|
curve curves.Curve
|
||||||
|
generators ippGenerators
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewInnerProductVerifier initializes a new verifier
|
||||||
|
// It uses the specified domain to generate generators for vectors of at most maxVectorLength
|
||||||
|
// A verifier can be used to verify inner product proofs for vectors of length less than or equal to maxVectorLength
|
||||||
|
// A verifier is defined by an explicit curve.
|
||||||
|
func NewInnerProductVerifier(maxVectorLength int, domain []byte, curve curves.Curve) (*InnerProductVerifier, error) {
|
||||||
|
generators, err := getGeneratorPoints(maxVectorLength, domain, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "ipp getGenerators")
|
||||||
|
}
|
||||||
|
return &InnerProductVerifier{curve: curve, generators: *generators}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify verifies the given proof inputs
|
||||||
|
// It implements the final comparison of section 3.1 on pg17 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func (verifier *InnerProductVerifier) Verify(capP, u curves.Point, proof *InnerProductProof, transcript *merlin.Transcript) (bool, error) {
|
||||||
|
if len(proof.capLs) != len(proof.capRs) {
|
||||||
|
return false, errors.New("ipp capLs and capRs must be same length")
|
||||||
|
}
|
||||||
|
// Generator vectors must be same length
|
||||||
|
if len(verifier.generators.G) != len(verifier.generators.H) {
|
||||||
|
return false, errors.New("ipp generator lengths of g and h must be equal")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get generators for each elem in a, b and one more for u
|
||||||
|
// len(Ls) = log n, therefore can just exponentiate
|
||||||
|
n := 1 << len(proof.capLs)
|
||||||
|
|
||||||
|
// Length of vectors must be less than the number of generators generated
|
||||||
|
if n > len(verifier.generators.G) {
|
||||||
|
return false, errors.New("ipp vector length must be less than maxVectorLength")
|
||||||
|
}
|
||||||
|
// In case where len(a) is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := verifier.generators.G[0:n]
|
||||||
|
proofH := verifier.generators.H[0:n]
|
||||||
|
|
||||||
|
xs, err := getxs(transcript, proof.capLs, proof.capRs, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verifier getxs")
|
||||||
|
}
|
||||||
|
s, err := verifier.getsNew(xs, n)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verifier getss")
|
||||||
|
}
|
||||||
|
lhs, err := verifier.getLHS(u, proof, proofG, proofH, s)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verify getLHS")
|
||||||
|
}
|
||||||
|
rhs, err := verifier.getRHS(capP, proof, xs)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verify getRHS")
|
||||||
|
}
|
||||||
|
return lhs.Equal(rhs), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify verifies the given proof inputs
|
||||||
|
// It implements the final comparison of section 3.1 on pg17 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func (verifier *InnerProductVerifier) VerifyFromRangeProof(proofG, proofH []curves.Point, capPhmuinv, u curves.Point, tHat curves.Scalar, proof *InnerProductProof, transcript *merlin.Transcript) (bool, error) {
|
||||||
|
// Get generators for each elem in a, b and one more for u
|
||||||
|
// len(Ls) = log n, therefore can just exponentiate
|
||||||
|
n := 1 << len(proof.capLs)
|
||||||
|
|
||||||
|
xs, err := getxs(transcript, proof.capLs, proof.capRs, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verifier getxs")
|
||||||
|
}
|
||||||
|
s, err := verifier.gets(xs, n)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verifier getss")
|
||||||
|
}
|
||||||
|
lhs, err := verifier.getLHS(u, proof, proofG, proofH, s)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verify getLHS")
|
||||||
|
}
|
||||||
|
utHat := u.Mul(tHat)
|
||||||
|
capP := capPhmuinv.Add(utHat)
|
||||||
|
rhs, err := verifier.getRHS(capP, proof, xs)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "verify getRHS")
|
||||||
|
}
|
||||||
|
return lhs.Equal(rhs), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getRHS gets the right hand side of the final comparison of section 3.1 on pg17.
|
||||||
|
func (*InnerProductVerifier) getRHS(capP curves.Point, proof *InnerProductProof, xs []curves.Scalar) (curves.Point, error) {
|
||||||
|
product := capP
|
||||||
|
for j, Lj := range proof.capLs {
|
||||||
|
Rj := proof.capRs[j]
|
||||||
|
xj := xs[j]
|
||||||
|
xjSquare := xj.Square()
|
||||||
|
xjSquareInv, err := xjSquare.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "verify invert")
|
||||||
|
}
|
||||||
|
LjxjSquare := Lj.Mul(xjSquare)
|
||||||
|
RjxjSquareInv := Rj.Mul(xjSquareInv)
|
||||||
|
product = product.Add(LjxjSquare).Add(RjxjSquareInv)
|
||||||
|
}
|
||||||
|
return product, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getLHS gets the left hand side of the final comparison of section 3.1 on pg17.
|
||||||
|
func (verifier *InnerProductVerifier) getLHS(u curves.Point, proof *InnerProductProof, g, h []curves.Point, s []curves.Scalar) (curves.Point, error) {
|
||||||
|
sInv, err := invertScalars(s)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "verify invertScalars")
|
||||||
|
}
|
||||||
|
// g^(a*s)
|
||||||
|
as := multiplyScalarToScalarVector(proof.a, s)
|
||||||
|
gas := verifier.curve.Point.SumOfProducts(g, as)
|
||||||
|
// h^(b*s^-1)
|
||||||
|
bsInv := multiplyScalarToScalarVector(proof.b, sInv)
|
||||||
|
hbsInv := verifier.curve.Point.SumOfProducts(h, bsInv)
|
||||||
|
// u^a*b
|
||||||
|
ab := proof.a.Mul(proof.b)
|
||||||
|
uab := u.Mul(ab)
|
||||||
|
// g^(a*s) * h^(b*s^-1) * u^a*b
|
||||||
|
out := gas.Add(hbsInv).Add(uab)
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getxs calculates the x values from Ls and Rs
|
||||||
|
// Note that each x is read from the transcript, then the L and R at a certain index are written to the transcript
|
||||||
|
// This mirrors the reading of xs and writing of Ls and Rs in the prover.
|
||||||
|
func getxs(transcript *merlin.Transcript, capLs, capRs []curves.Point, curve curves.Curve) ([]curves.Scalar, error) {
|
||||||
|
xs := make([]curves.Scalar, len(capLs))
|
||||||
|
for i, capLi := range capLs {
|
||||||
|
capRi := capRs[i]
|
||||||
|
// Add the newest L and R values to transcript
|
||||||
|
transcript.AppendMessage([]byte("addRecursiveL"), capLi.ToAffineUncompressed())
|
||||||
|
transcript.AppendMessage([]byte("addRecursiveR"), capRi.ToAffineUncompressed())
|
||||||
|
// Read 64 bytes from, set to scalar
|
||||||
|
outBytes := transcript.ExtractBytes([]byte("getx"), 64)
|
||||||
|
x, err := curve.NewScalar().SetBytesWide(outBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "calcx NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
xs[i] = x
|
||||||
|
}
|
||||||
|
|
||||||
|
return xs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// gets calculates the vector s of values used for verification
|
||||||
|
// See the second expression of section 3.1 on pg15
|
||||||
|
// nolint
|
||||||
|
func (verifier *InnerProductVerifier) gets(xs []curves.Scalar, n int) ([]curves.Scalar, error) {
|
||||||
|
ss := make([]curves.Scalar, n)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
si := verifier.curve.Scalar.One()
|
||||||
|
for j, xj := range xs {
|
||||||
|
if i>>(len(xs)-j-1)&0x01 == 1 {
|
||||||
|
si = si.Mul(xj)
|
||||||
|
} else {
|
||||||
|
xjInverse, err := xj.Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "getss invert")
|
||||||
|
}
|
||||||
|
si = si.Mul(xjInverse)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ss[i] = si
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getsNew calculates the vector s of values used for verification
|
||||||
|
// It provides analogous functionality as gets(), but uses a O(n) algorithm vs O(nlogn)
|
||||||
|
// The algorithm inverts all xs, then begins multiplying the inversion by the square of x elements to
|
||||||
|
// calculate all s values thus minimizing necessary inversions/ computation.
|
||||||
|
func (verifier *InnerProductVerifier) getsNew(xs []curves.Scalar, n int) ([]curves.Scalar, error) {
|
||||||
|
var err error
|
||||||
|
ss := make([]curves.Scalar, n)
|
||||||
|
// First element is all xs inverted mul'd
|
||||||
|
ss[0] = verifier.curve.Scalar.One()
|
||||||
|
for _, xj := range xs {
|
||||||
|
ss[0] = ss[0].Mul(xj)
|
||||||
|
}
|
||||||
|
ss[0], err = ss[0].Invert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "ipp gets inv ss0")
|
||||||
|
}
|
||||||
|
for j, xj := range xs {
|
||||||
|
xjSquared := xj.Square()
|
||||||
|
for i := 0; i < n; i += 1 << (len(xs) - j) {
|
||||||
|
ss[i+1<<(len(xs)-j-1)] = ss[i].Mul(xjSquared)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ss, nil
|
||||||
|
}
|
||||||
Executable
+79
@@ -0,0 +1,79 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIPPVerifyHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
vecLength := 256
|
||||||
|
prover, err := NewInnerProductProver(vecLength, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
a := randScalarVec(vecLength, *curve)
|
||||||
|
b := randScalarVec(vecLength, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcriptProver := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(a, b, u, transcriptProver)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewInnerProductVerifier(vecLength, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
capP, err := prover.getP(a, b, u)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
verified, err := verifier.Verify(capP, u, proof, transcriptVerifier)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, verified)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkIPPVerification(bench *testing.B) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
vecLength := 1024
|
||||||
|
prover, _ := NewInnerProductProver(vecLength, []byte("test"), *curve)
|
||||||
|
a := randScalarVec(vecLength, *curve)
|
||||||
|
b := randScalarVec(vecLength, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
transcriptProver := merlin.NewTranscript("test")
|
||||||
|
proof, _ := prover.Prove(a, b, u, transcriptProver)
|
||||||
|
|
||||||
|
verifier, _ := NewInnerProductVerifier(vecLength, []byte("test"), *curve)
|
||||||
|
capP, _ := prover.getP(a, b, u)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
verified, _ := verifier.Verify(capP, u, proof, transcriptVerifier)
|
||||||
|
require.True(bench, verified)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIPPVerifyInvalidProof(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
vecLength := 64
|
||||||
|
prover, err := NewInnerProductProver(vecLength, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
a := randScalarVec(vecLength, *curve)
|
||||||
|
b := randScalarVec(vecLength, *curve)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
|
||||||
|
aPrime := randScalarVec(64, *curve)
|
||||||
|
bPrime := randScalarVec(64, *curve)
|
||||||
|
uPrime := curve.Point.Random(crand.Reader)
|
||||||
|
transcriptProver := merlin.NewTranscript("test")
|
||||||
|
|
||||||
|
proofPrime, err := prover.Prove(aPrime, bPrime, uPrime, transcriptProver)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewInnerProductVerifier(vecLength, []byte("test"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
capP, err := prover.getP(a, b, u)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
// Check for different capP, u from proof
|
||||||
|
verified, err := verifier.Verify(capP, u, proofPrime, transcriptVerifier)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.False(t, verified)
|
||||||
|
}
|
||||||
Executable
+348
@@ -0,0 +1,348 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BatchProve proves that a list of scalars v are in the range n.
|
||||||
|
// It implements the aggregating logarithmic proofs defined on pg21.
|
||||||
|
// Instead of taking a single value and a single blinding factor, BatchProve takes in a list of values and list of
|
||||||
|
// blinding factors.
|
||||||
|
func (prover *RangeProver) BatchProve(v, gamma []curves.Scalar, n int, proofGenerators RangeProofGenerators, transcript *merlin.Transcript) (*RangeProof, error) {
|
||||||
|
// Define nm as the total bits required for secrets, calculated as number of secrets * n
|
||||||
|
m := len(v)
|
||||||
|
nm := n * m
|
||||||
|
// nm must be less than or equal to the number of generators generated
|
||||||
|
if nm > len(prover.generators.G) {
|
||||||
|
return nil, errors.New("ipp vector length must be less than or equal to maxVectorLength")
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case where nm is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := prover.generators.G[0:nm]
|
||||||
|
proofH := prover.generators.H[0:nm]
|
||||||
|
|
||||||
|
// Check that each elem in v is in range [0, 2^n]
|
||||||
|
for _, vi := range v {
|
||||||
|
checkedRange := checkRange(vi, n)
|
||||||
|
if checkedRange != nil {
|
||||||
|
return nil, checkedRange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// L40 on pg19
|
||||||
|
aL, err := getaLBatched(v, n, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
onenm := get1nVector(nm, prover.curve)
|
||||||
|
// L41 on pg19
|
||||||
|
aR, err := subtractPairwiseScalarVectors(aL, onenm)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
alpha := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
// Calc A (L44, pg19)
|
||||||
|
halpha := proofGenerators.h.Mul(alpha)
|
||||||
|
gaL := prover.curve.Point.SumOfProducts(proofG, aL)
|
||||||
|
haR := prover.curve.Point.SumOfProducts(proofH, aR)
|
||||||
|
capA := halpha.Add(gaL).Add(haR)
|
||||||
|
|
||||||
|
// L45, 46, pg19
|
||||||
|
sL := getBlindingVector(nm, prover.curve)
|
||||||
|
sR := getBlindingVector(nm, prover.curve)
|
||||||
|
rho := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
|
||||||
|
// Calc S (L47, pg19)
|
||||||
|
hrho := proofGenerators.h.Mul(rho)
|
||||||
|
gsL := prover.curve.Point.SumOfProducts(proofG, sL)
|
||||||
|
hsR := prover.curve.Point.SumOfProducts(proofH, sR)
|
||||||
|
capS := hrho.Add(gsL).Add(hsR)
|
||||||
|
|
||||||
|
// Fiat Shamir for y,z (L49, pg19)
|
||||||
|
capV := getcapVBatched(v, gamma, proofGenerators.g, proofGenerators.h)
|
||||||
|
y, z, err := calcyzBatched(capV, capA, capS, transcript, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc t_1, t_2
|
||||||
|
// See the l(X), r(X), equations on pg 21
|
||||||
|
// Use l(X)'s and r(X)'s constant and linear terms to derive t_1 and t_2
|
||||||
|
// (a_l - z*1^n)
|
||||||
|
zonenm := multiplyScalarToScalarVector(z, onenm)
|
||||||
|
constantTerml, err := subtractPairwiseScalarVectors(aL, zonenm)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
linearTerml := sL
|
||||||
|
|
||||||
|
// zSum term, see equation 71 on pg21
|
||||||
|
zSum := getSumTermrXBatched(z, n, len(v), prover.curve)
|
||||||
|
// a_r + z*1^nm
|
||||||
|
aRPluszonenm, err := addPairwiseScalarVectors(aR, zonenm)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
ynm := getknVector(y, nm, prover.curve)
|
||||||
|
hadamard, err := multiplyPairwiseScalarVectors(ynm, aRPluszonenm)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
constantTermr, err := addPairwiseScalarVectors(hadamard, zSum)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
linearTermr, err := multiplyPairwiseScalarVectors(ynm, sR)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// t_1 (as the linear coefficient) is the sum of the dot products of l(X)'s linear term dot r(X)'s constant term
|
||||||
|
// and r(X)'s linear term dot l(X)'s constant term
|
||||||
|
t1FirstTerm, err := innerProduct(linearTerml, constantTermr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
t1SecondTerm, err := innerProduct(linearTermr, constantTerml)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
t1 := t1FirstTerm.Add(t1SecondTerm)
|
||||||
|
|
||||||
|
// t_2 (as the quadratic coefficient) is the dot product of l(X)'s and r(X)'s linear terms
|
||||||
|
t2, err := innerProduct(linearTerml, linearTermr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// L52, pg20
|
||||||
|
tau1 := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
tau2 := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
|
||||||
|
// T_1, T_2 (L53, pg20)
|
||||||
|
capT1 := proofGenerators.g.Mul(t1).Add(proofGenerators.h.Mul(tau1))
|
||||||
|
capT2 := proofGenerators.g.Mul(t2).Add(proofGenerators.h.Mul(tau2))
|
||||||
|
|
||||||
|
// Fiat shamir for x (L55, pg20)
|
||||||
|
x, err := calcx(capT1, capT2, transcript, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc l
|
||||||
|
// Instead of using the expression in the line, evaluate l() at x
|
||||||
|
sLx := multiplyScalarToScalarVector(x, linearTerml)
|
||||||
|
l, err := addPairwiseScalarVectors(constantTerml, sLx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc r
|
||||||
|
// Instead of using the expression in the line, evaluate r() at x
|
||||||
|
ynsRx := multiplyScalarToScalarVector(x, linearTermr)
|
||||||
|
r, err := addPairwiseScalarVectors(constantTermr, ynsRx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc t hat
|
||||||
|
// For efficiency, instead of calculating the dot product, evaluate t() at x
|
||||||
|
zm := getknVector(z, m, prover.curve)
|
||||||
|
zsquarezm := multiplyScalarToScalarVector(z.Square(), zm)
|
||||||
|
sumv := prover.curve.Scalar.Zero()
|
||||||
|
for i := 0; i < m; i++ {
|
||||||
|
elem := zsquarezm[i].Mul(v[i])
|
||||||
|
sumv = sumv.Add(elem)
|
||||||
|
}
|
||||||
|
|
||||||
|
deltayzBatched, err := deltayzBatched(y, z, n, m, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
t0 := sumv.Add(deltayzBatched)
|
||||||
|
tLinear := t1.Mul(x)
|
||||||
|
tQuadratic := t2.Mul(x.Square())
|
||||||
|
tHat := t0.Add(tLinear).Add(tQuadratic)
|
||||||
|
|
||||||
|
// Calc tau_x (L61, pg20)
|
||||||
|
tau2xsquare := tau2.Mul(x.Square())
|
||||||
|
tau1x := tau1.Mul(x)
|
||||||
|
zsum := prover.curve.Scalar.Zero()
|
||||||
|
zExp := z.Clone()
|
||||||
|
for j := 1; j < m+1; j++ {
|
||||||
|
zExp = zExp.Mul(z)
|
||||||
|
zsum = zsum.Add(zExp.Mul(gamma[j-1]))
|
||||||
|
}
|
||||||
|
taux := tau2xsquare.Add(tau1x).Add(zsum)
|
||||||
|
|
||||||
|
// Calc mu (L62, pg20)
|
||||||
|
mu := alpha.Add(rho.Mul(x))
|
||||||
|
|
||||||
|
// Calc IPP (See section 4.2)
|
||||||
|
hPrime, err := gethPrime(proofH, y, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// P is redefined in batched case, see bottom equation on pg21.
|
||||||
|
capPhmu := getPhmuBatched(proofG, hPrime, proofGenerators.h, capA, capS, x, y, z, mu, n, m, prover.curve)
|
||||||
|
|
||||||
|
wBytes := transcript.ExtractBytes([]byte("getw"), 64)
|
||||||
|
w, err := prover.curve.NewScalar().SetBytesWide(wBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
ipp, err := prover.ippProver.rangeToIPP(proofG, hPrime, l, r, tHat, capPhmu, proofGenerators.u.Mul(w), transcript)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
out := &RangeProof{
|
||||||
|
capA: capA,
|
||||||
|
capS: capS,
|
||||||
|
capT1: capT1,
|
||||||
|
capT2: capT2,
|
||||||
|
taux: taux,
|
||||||
|
mu: mu,
|
||||||
|
tHat: tHat,
|
||||||
|
ipp: ipp,
|
||||||
|
curve: &prover.curve,
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// See final term of L71 on pg 21
|
||||||
|
// Sigma_{j=1}^{m} z^{1+j} * (0^{(j-1)*n} || 2^{n} || 0^{(m-j)*n}).
|
||||||
|
func getSumTermrXBatched(z curves.Scalar, n, m int, curve curves.Curve) []curves.Scalar {
|
||||||
|
twoN := get2nVector(n, curve)
|
||||||
|
var out []curves.Scalar
|
||||||
|
// The final power should be one more than m
|
||||||
|
zExp := z.Clone()
|
||||||
|
for j := 0; j < m; j++ {
|
||||||
|
zExp = zExp.Mul(z)
|
||||||
|
elem := multiplyScalarToScalarVector(zExp, twoN)
|
||||||
|
out = append(out, elem...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func getcapVBatched(v, gamma []curves.Scalar, g, h curves.Point) []curves.Point {
|
||||||
|
out := make([]curves.Point, len(v))
|
||||||
|
for i, vi := range v {
|
||||||
|
out[i] = getcapV(vi, gamma[i], g, h)
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
func getaLBatched(v []curves.Scalar, n int, curve curves.Curve) ([]curves.Scalar, error) {
|
||||||
|
var aL []curves.Scalar
|
||||||
|
for _, vi := range v {
|
||||||
|
aLi, err := getaL(vi, n, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
aL = append(aL, aLi...)
|
||||||
|
}
|
||||||
|
return aL, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func calcyzBatched(capV []curves.Point, capA, capS curves.Point, transcript *merlin.Transcript, curve curves.Curve) (curves.Scalar, curves.Scalar, error) {
|
||||||
|
// Add the A,S values to transcript
|
||||||
|
for _, capVi := range capV {
|
||||||
|
transcript.AppendMessage([]byte("addV"), capVi.ToAffineUncompressed())
|
||||||
|
}
|
||||||
|
transcript.AppendMessage([]byte("addcapA"), capA.ToAffineUncompressed())
|
||||||
|
transcript.AppendMessage([]byte("addcapS"), capS.ToAffineUncompressed())
|
||||||
|
// Read 64 bytes twice from, set to scalar for y and z
|
||||||
|
yBytes := transcript.ExtractBytes([]byte("gety"), 64)
|
||||||
|
y, err := curve.NewScalar().SetBytesWide(yBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "calcyz NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
zBytes := transcript.ExtractBytes([]byte("getz"), 64)
|
||||||
|
z, err := curve.NewScalar().SetBytesWide(zBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "calcyz NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
|
||||||
|
return y, z, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func deltayzBatched(y, z curves.Scalar, n, m int, curve curves.Curve) (curves.Scalar, error) {
|
||||||
|
// z - z^2
|
||||||
|
zMinuszsquare := z.Sub(z.Square())
|
||||||
|
// 1^(n*m)
|
||||||
|
onenm := get1nVector(n*m, curve)
|
||||||
|
// <1^nm, y^nm>
|
||||||
|
onenmdotynm, err := innerProduct(onenm, getknVector(y, n*m, curve))
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "deltayz")
|
||||||
|
}
|
||||||
|
// (z - z^2)*<1^n, y^n>
|
||||||
|
termFirst := zMinuszsquare.Mul(onenmdotynm)
|
||||||
|
|
||||||
|
// <1^n, 2^n>
|
||||||
|
onendottwon, err := innerProduct(get1nVector(n, curve), get2nVector(n, curve))
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "deltayz")
|
||||||
|
}
|
||||||
|
|
||||||
|
termSecond := curve.Scalar.Zero()
|
||||||
|
zExp := z.Square()
|
||||||
|
for j := 1; j < m+1; j++ {
|
||||||
|
zExp = zExp.Mul(z)
|
||||||
|
elem := zExp.Mul(onendottwon)
|
||||||
|
termSecond = termSecond.Add(elem)
|
||||||
|
}
|
||||||
|
|
||||||
|
// (z - z^2)*<1^n, y^n> - z^3*<1^n, 2^n>
|
||||||
|
out := termFirst.Sub(termSecond)
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bottom equation on pg21.
|
||||||
|
func getPhmuBatched(proofG, proofHPrime []curves.Point, h, capA, capS curves.Point, x, y, z, mu curves.Scalar, n, m int, curve curves.Curve) curves.Point {
|
||||||
|
twoN := get2nVector(n, curve)
|
||||||
|
// h'^(z*y^n + z^2*2^n)
|
||||||
|
lastElem := curve.NewIdentityPoint()
|
||||||
|
zExp := z.Clone()
|
||||||
|
for j := 1; j < m+1; j++ {
|
||||||
|
// Get subvector of h
|
||||||
|
hSubvector := proofHPrime[(j-1)*n : j*n]
|
||||||
|
// z^(j+1)
|
||||||
|
zExp = zExp.Mul(z)
|
||||||
|
exp := multiplyScalarToScalarVector(zExp, twoN)
|
||||||
|
// Final elem
|
||||||
|
elem := curve.Point.SumOfProducts(hSubvector, exp)
|
||||||
|
lastElem = lastElem.Add(elem)
|
||||||
|
}
|
||||||
|
|
||||||
|
zynm := multiplyScalarToScalarVector(z, getknVector(y, n*m, curve))
|
||||||
|
hPrimezynm := curve.Point.SumOfProducts(proofHPrime, zynm)
|
||||||
|
lastElem = lastElem.Add(hPrimezynm)
|
||||||
|
|
||||||
|
// S^x
|
||||||
|
capSx := capS.Mul(x)
|
||||||
|
|
||||||
|
// g^-z --> -z*<1,g>
|
||||||
|
onenm := get1nVector(n*m, curve)
|
||||||
|
zNeg := z.Neg()
|
||||||
|
zinvonen := multiplyScalarToScalarVector(zNeg, onenm)
|
||||||
|
zgdotonen := curve.Point.SumOfProducts(proofG, zinvonen)
|
||||||
|
|
||||||
|
// L66 on pg20
|
||||||
|
P := capA.Add(capSx).Add(zgdotonen).Add(lastElem)
|
||||||
|
hmu := h.Mul(mu)
|
||||||
|
Phmu := P.Sub(hmu)
|
||||||
|
|
||||||
|
return Phmu
|
||||||
|
}
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRangeBatchProverHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 256
|
||||||
|
prover, err := NewRangeProver(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
|
||||||
|
gamma1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := []curves.Scalar{gamma1, gamma2, gamma3, gamma4}
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.BatchProve(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, proof)
|
||||||
|
require.Equal(t, 10, len(proof.ipp.capLs))
|
||||||
|
require.Equal(t, 10, len(proof.ipp.capRs))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetaLBatched(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
v1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
aL, err := getaLBatched(v, 256, *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
twoN := get2nVector(256, *curve)
|
||||||
|
for i := 1; i < len(v)+1; i++ {
|
||||||
|
vec := aL[(i-1)*256 : i*256]
|
||||||
|
product, err := innerProduct(vec, twoN)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, product.Cmp(v[i-1]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeBatchProverMarshal(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 256
|
||||||
|
prover, err := NewRangeProver(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
|
||||||
|
gamma1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := []curves.Scalar{gamma1, gamma2, gamma3, gamma4}
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.BatchProve(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
proofMarshaled := proof.MarshalBinary()
|
||||||
|
proofPrime := NewRangeProof(curve)
|
||||||
|
err = proofPrime.UnmarshalBinary(proofMarshaled)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, proof.capA.Equal(proofPrime.capA))
|
||||||
|
require.True(t, proof.capS.Equal(proofPrime.capS))
|
||||||
|
require.True(t, proof.capT1.Equal(proofPrime.capT1))
|
||||||
|
require.True(t, proof.capT2.Equal(proofPrime.capT2))
|
||||||
|
require.Zero(t, proof.taux.Cmp(proofPrime.taux))
|
||||||
|
require.Zero(t, proof.mu.Cmp(proofPrime.mu))
|
||||||
|
require.Zero(t, proof.tHat.Cmp(proofPrime.tHat))
|
||||||
|
}
|
||||||
Executable
+91
@@ -0,0 +1,91 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VerifyBatched verifies a given batched range proof.
|
||||||
|
// It takes in a list of commitments to the secret values as capV instead of a single commitment to a single point
|
||||||
|
// when compared to the unbatched single range proof case.
|
||||||
|
func (verifier *RangeVerifier) VerifyBatched(proof *RangeProof, capV []curves.Point, proofGenerators RangeProofGenerators, n int, transcript *merlin.Transcript) (bool, error) {
|
||||||
|
// Define nm as the total bits required for secrets, calculated as number of secrets * n
|
||||||
|
m := len(capV)
|
||||||
|
nm := n * m
|
||||||
|
// nm must be less than the number of generators generated
|
||||||
|
if nm > len(verifier.generators.G) {
|
||||||
|
return false, errors.New("ipp vector length must be less than maxVectorLength")
|
||||||
|
}
|
||||||
|
|
||||||
|
// In case where len(a) is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := verifier.generators.G[0:nm]
|
||||||
|
proofH := verifier.generators.H[0:nm]
|
||||||
|
|
||||||
|
// Calc y,z,x from Fiat Shamir heuristic
|
||||||
|
y, z, err := calcyzBatched(capV, proof.capA, proof.capS, transcript, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
x, err := calcx(proof.capT1, proof.capT2, transcript, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
wBytes := transcript.ExtractBytes([]byte("getw"), 64)
|
||||||
|
w, err := verifier.curve.NewScalar().SetBytesWide(wBytes)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc delta(y,z), redefined for batched case on pg21
|
||||||
|
deltayzBatched, err := deltayzBatched(y, z, n, m, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check tHat: L65, pg20
|
||||||
|
// See equation 72 on pg21
|
||||||
|
tHatIsValid := verifier.checktHatBatched(proof, capV, proofGenerators.g, proofGenerators.h, deltayzBatched, x, z, m)
|
||||||
|
if !tHatIsValid {
|
||||||
|
return false, errors.New("rangeproof verify tHat is invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify IPP
|
||||||
|
hPrime, err := gethPrime(proofH, y, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
capPhmu := getPhmuBatched(proofG, hPrime, proofGenerators.h, proof.capA, proof.capS, x, y, z, proof.mu, n, m, verifier.curve)
|
||||||
|
|
||||||
|
ippVerified, err := verifier.ippVerifier.VerifyFromRangeProof(proofG, hPrime, capPhmu, proofGenerators.u.Mul(w), proof.tHat, proof.ipp, transcript)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ippVerified, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// L65, pg20.
|
||||||
|
func (verifier *RangeVerifier) checktHatBatched(proof *RangeProof, capV []curves.Point, g, h curves.Point, deltayz, x, z curves.Scalar, m int) bool {
|
||||||
|
// g^tHat * h^tau_x
|
||||||
|
gtHat := g.Mul(proof.tHat)
|
||||||
|
htaux := h.Mul(proof.taux)
|
||||||
|
lhs := gtHat.Add(htaux)
|
||||||
|
|
||||||
|
// V^z^2 * g^delta(y,z) * Tau_1^x * Tau_2^x^2
|
||||||
|
// g^delta(y,z) * V^(z^2*z^m) * Tau_1^x * Tau_2^x^2
|
||||||
|
zm := getknVector(z, m, verifier.curve)
|
||||||
|
zsquarezm := multiplyScalarToScalarVector(z.Square(), zm)
|
||||||
|
capVzsquaretwom := verifier.curve.Point.SumOfProducts(capV, zsquarezm)
|
||||||
|
gdeltayz := g.Mul(deltayz)
|
||||||
|
capTau1x := proof.capT1.Mul(x)
|
||||||
|
capTau2xsquare := proof.capT2.Mul(x.Square())
|
||||||
|
rhs := capVzsquaretwom.Add(gdeltayz).Add(capTau1x).Add(capTau2xsquare)
|
||||||
|
|
||||||
|
// Compare lhs =? rhs
|
||||||
|
return lhs.Equal(rhs)
|
||||||
|
}
|
||||||
+148
@@ -0,0 +1,148 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRangeBatchVerifyHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 256
|
||||||
|
prover, err := NewRangeProver(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
gamma1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := []curves.Scalar{gamma1, gamma2, gamma3, gamma4}
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.BatchProve(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewRangeVerifier(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
capV := getcapVBatched(v, gamma, g, h)
|
||||||
|
verified, err := verifier.VerifyBatched(proof, capV, proofGenerators, n, transcriptVerifier)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, verified)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeBatchVerifyNotInRange(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 2
|
||||||
|
prover, err := NewRangeProver(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v1 := curve.Scalar.One()
|
||||||
|
v2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
gamma1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := []curves.Scalar{gamma1, gamma2, gamma3, gamma4}
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
_, err = prover.BatchProve(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeBatchVerifyNonRandom(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 2
|
||||||
|
prover, err := NewRangeProver(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v1 := curve.Scalar.One()
|
||||||
|
v2 := curve.Scalar.One()
|
||||||
|
v3 := curve.Scalar.One()
|
||||||
|
v4 := curve.Scalar.One()
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
gamma1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := []curves.Scalar{gamma1, gamma2, gamma3, gamma4}
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.BatchProve(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewRangeVerifier(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
capV := getcapVBatched(v, gamma, g, h)
|
||||||
|
verified, err := verifier.VerifyBatched(proof, capV, proofGenerators, n, transcriptVerifier)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, verified)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeBatchVerifyInvalid(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 2
|
||||||
|
prover, err := NewRangeProver(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v1 := curve.Scalar.One()
|
||||||
|
v2 := curve.Scalar.One()
|
||||||
|
v3 := curve.Scalar.One()
|
||||||
|
v4 := curve.Scalar.One()
|
||||||
|
v := []curves.Scalar{v1, v2, v3, v4}
|
||||||
|
gamma1 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma2 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma3 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma4 := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := []curves.Scalar{gamma1, gamma2, gamma3, gamma4}
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.BatchProve(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewRangeVerifier(n*4, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
capV := getcapVBatched(v, gamma, g, h)
|
||||||
|
capV[0] = curve.Point.Random(crand.Reader)
|
||||||
|
verified, err := verifier.VerifyBatched(proof, capV, proofGenerators, n, transcriptVerifier)
|
||||||
|
require.Error(t, err)
|
||||||
|
require.False(t, verified)
|
||||||
|
}
|
||||||
Executable
+476
@@ -0,0 +1,476 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
// Package bulletproof implements the zero knowledge protocol bulletproofs as defined in https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RangeProver is the struct used to create RangeProofs
|
||||||
|
// It specifies which curve to use and holds precomputed generators
|
||||||
|
// See NewRangeProver() for prover initialization.
|
||||||
|
type RangeProver struct {
|
||||||
|
curve curves.Curve
|
||||||
|
generators *ippGenerators
|
||||||
|
ippProver *InnerProductProver
|
||||||
|
}
|
||||||
|
|
||||||
|
// RangeProof is the struct used to hold a range proof
|
||||||
|
// capA is a commitment to a_L and a_R using randomness alpha
|
||||||
|
// capS is a commitment to s_L and s_R using randomness rho
|
||||||
|
// capTau1,2 are commitments to t1,t2 respectively using randomness tau_1,2
|
||||||
|
// tHat represents t(X) as defined on page 19
|
||||||
|
// taux is the blinding factor for tHat
|
||||||
|
// ipp is the inner product proof used for compacting the transfer of l,r (See 4.2 on pg20).
|
||||||
|
type RangeProof struct {
|
||||||
|
capA, capS, capT1, capT2 curves.Point
|
||||||
|
taux, mu, tHat curves.Scalar
|
||||||
|
ipp *InnerProductProof
|
||||||
|
curve *curves.Curve
|
||||||
|
}
|
||||||
|
|
||||||
|
type RangeProofGenerators struct {
|
||||||
|
g, h, u curves.Point
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRangeProver initializes a new prover
|
||||||
|
// It uses the specified domain to generate generators for vectors of at most maxVectorLength
|
||||||
|
// A prover can be used to construct range proofs for vectors of length less than or equal to maxVectorLength
|
||||||
|
// A prover is defined by an explicit curve.
|
||||||
|
func NewRangeProver(maxVectorLength int, rangeDomain, ippDomain []byte, curve curves.Curve) (*RangeProver, error) {
|
||||||
|
generators, err := getGeneratorPoints(maxVectorLength, rangeDomain, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "range NewRangeProver")
|
||||||
|
}
|
||||||
|
ippProver, err := NewInnerProductProver(maxVectorLength, ippDomain, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "range NewRangeProver")
|
||||||
|
}
|
||||||
|
return &RangeProver{curve: curve, generators: generators, ippProver: ippProver}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRangeProof initializes a new RangeProof for a specified curve
|
||||||
|
// This should be used in tandem with UnmarshalBinary() to convert a marshaled proof into the struct.
|
||||||
|
func NewRangeProof(curve *curves.Curve) *RangeProof {
|
||||||
|
out := RangeProof{
|
||||||
|
capA: nil,
|
||||||
|
capS: nil,
|
||||||
|
capT1: nil,
|
||||||
|
capT2: nil,
|
||||||
|
taux: nil,
|
||||||
|
mu: nil,
|
||||||
|
tHat: nil,
|
||||||
|
ipp: NewInnerProductProof(curve),
|
||||||
|
curve: curve,
|
||||||
|
}
|
||||||
|
|
||||||
|
return &out
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prove uses the range prover to prove that some value v is within the range [0, 2^n]
|
||||||
|
// It implements the protocol defined on pgs 19,20 in https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
// v is the value of which to prove the range
|
||||||
|
// n is the power that specifies the upper bound of the range, ie. 2^n
|
||||||
|
// gamma is a scalar used for as a blinding factor
|
||||||
|
// g, h, u are unique points used as generators for the blinding factor
|
||||||
|
// transcript is a merlin transcript to be used for the fiat shamir heuristic.
|
||||||
|
func (prover *RangeProver) Prove(v, gamma curves.Scalar, n int, proofGenerators RangeProofGenerators, transcript *merlin.Transcript) (*RangeProof, error) {
|
||||||
|
// n must be less than or equal to the number of generators generated
|
||||||
|
if n > len(prover.generators.G) {
|
||||||
|
return nil, errors.New("ipp vector length must be less than or equal to maxVectorLength")
|
||||||
|
}
|
||||||
|
// In case where len(a) is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := prover.generators.G[0:n]
|
||||||
|
proofH := prover.generators.H[0:n]
|
||||||
|
|
||||||
|
// Check that v is in range [0, 2^n]
|
||||||
|
if bigZero := big.NewInt(0); v.BigInt().Cmp(bigZero) == -1 {
|
||||||
|
return nil, errors.New("v is less than 0")
|
||||||
|
}
|
||||||
|
|
||||||
|
bigTwo := big.NewInt(2)
|
||||||
|
if n < 0 {
|
||||||
|
return nil, errors.New("n cannot be less than 0")
|
||||||
|
}
|
||||||
|
bigN := big.NewInt(int64(n))
|
||||||
|
var bigTwoToN big.Int
|
||||||
|
bigTwoToN.Exp(bigTwo, bigN, nil)
|
||||||
|
if v.BigInt().Cmp(&bigTwoToN) == 1 {
|
||||||
|
return nil, errors.New("v is greater than 2^n")
|
||||||
|
}
|
||||||
|
|
||||||
|
// L40 on pg19
|
||||||
|
aL, err := getaL(v, n, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
onen := get1nVector(n, prover.curve)
|
||||||
|
// L41 on pg19
|
||||||
|
aR, err := subtractPairwiseScalarVectors(aL, onen)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
alpha := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
// Calc A (L44, pg19)
|
||||||
|
halpha := proofGenerators.h.Mul(alpha)
|
||||||
|
gaL := prover.curve.Point.SumOfProducts(proofG, aL)
|
||||||
|
haR := prover.curve.Point.SumOfProducts(proofH, aR)
|
||||||
|
capA := halpha.Add(gaL).Add(haR)
|
||||||
|
|
||||||
|
// L45, 46, pg19
|
||||||
|
sL := getBlindingVector(n, prover.curve)
|
||||||
|
sR := getBlindingVector(n, prover.curve)
|
||||||
|
rho := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
|
||||||
|
// Calc S (L47, pg19)
|
||||||
|
hrho := proofGenerators.h.Mul(rho)
|
||||||
|
gsL := prover.curve.Point.SumOfProducts(proofG, sL)
|
||||||
|
hsR := prover.curve.Point.SumOfProducts(proofH, sR)
|
||||||
|
capS := hrho.Add(gsL).Add(hsR)
|
||||||
|
|
||||||
|
// Fiat Shamir for y,z (L49, pg19)
|
||||||
|
capV := getcapV(v, gamma, proofGenerators.g, proofGenerators.h)
|
||||||
|
y, z, err := calcyz(capV, capA, capS, transcript, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc t_1, t_2
|
||||||
|
// See the l(X), r(X), t(X) equations on pg 19
|
||||||
|
// Use l(X)'s and r(X)'s constant and linear terms to derive t_1 and t_2
|
||||||
|
// (a_l - z*1^n)
|
||||||
|
zonen := multiplyScalarToScalarVector(z, onen)
|
||||||
|
constantTerml, err := subtractPairwiseScalarVectors(aL, zonen)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
linearTerml := sL
|
||||||
|
|
||||||
|
// z^2 * 2^N
|
||||||
|
twoN := get2nVector(n, prover.curve)
|
||||||
|
zSquareTwon := multiplyScalarToScalarVector(z.Square(), twoN)
|
||||||
|
// a_r + z*1^n
|
||||||
|
aRPluszonen, err := addPairwiseScalarVectors(aR, zonen)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
yn := getknVector(y, n, prover.curve)
|
||||||
|
hadamard, err := multiplyPairwiseScalarVectors(yn, aRPluszonen)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
constantTermr, err := addPairwiseScalarVectors(hadamard, zSquareTwon)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
linearTermr, err := multiplyPairwiseScalarVectors(yn, sR)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// t_1 (as the linear coefficient) is the sum of the dot products of l(X)'s linear term dot r(X)'s constant term
|
||||||
|
// and r(X)'s linear term dot l(X)'s constant term
|
||||||
|
t1FirstTerm, err := innerProduct(linearTerml, constantTermr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
t1SecondTerm, err := innerProduct(linearTermr, constantTerml)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
t1 := t1FirstTerm.Add(t1SecondTerm)
|
||||||
|
|
||||||
|
// t_2 (as the quadratic coefficient) is the dot product of l(X)'s and r(X)'s linear terms
|
||||||
|
t2, err := innerProduct(linearTerml, linearTermr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// L52, pg20
|
||||||
|
tau1 := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
tau2 := prover.curve.Scalar.Random(crand.Reader)
|
||||||
|
|
||||||
|
// T_1, T_2 (L53, pg20)
|
||||||
|
capT1 := proofGenerators.g.Mul(t1).Add(proofGenerators.h.Mul(tau1))
|
||||||
|
capT2 := proofGenerators.g.Mul(t2).Add(proofGenerators.h.Mul(tau2))
|
||||||
|
|
||||||
|
// Fiat shamir for x (L55, pg20)
|
||||||
|
x, err := calcx(capT1, capT2, transcript, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc l (L58, pg20)
|
||||||
|
// Instead of using the expression in the line, evaluate l() at x
|
||||||
|
sLx := multiplyScalarToScalarVector(x, linearTerml)
|
||||||
|
l, err := addPairwiseScalarVectors(constantTerml, sLx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc r (L59, pg20)
|
||||||
|
// Instead of using the expression in the line, evaluate r() at x
|
||||||
|
ynsRx := multiplyScalarToScalarVector(x, linearTermr)
|
||||||
|
r, err := addPairwiseScalarVectors(constantTermr, ynsRx)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc t hat (L60, pg20)
|
||||||
|
// For efficiency, instead of calculating the dot product, evaluate t() at x
|
||||||
|
deltayz, err := deltayz(y, z, n, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
t0 := v.Mul(z.Square()).Add(deltayz)
|
||||||
|
tLinear := t1.Mul(x)
|
||||||
|
tQuadratic := t2.Mul(x.Square())
|
||||||
|
tHat := t0.Add(tLinear).Add(tQuadratic)
|
||||||
|
|
||||||
|
// Calc tau_x (L61, pg20)
|
||||||
|
tau2xsquare := tau2.Mul(x.Square())
|
||||||
|
tau1x := tau1.Mul(x)
|
||||||
|
zsquaregamma := z.Square().Mul(gamma)
|
||||||
|
taux := tau2xsquare.Add(tau1x).Add(zsquaregamma)
|
||||||
|
|
||||||
|
// Calc mu (L62, pg20)
|
||||||
|
mu := alpha.Add(rho.Mul(x))
|
||||||
|
|
||||||
|
// Calc IPP (See section 4.2)
|
||||||
|
hPrime, err := gethPrime(proofH, y, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
capPhmu, err := getPhmu(proofG, hPrime, proofGenerators.h, capA, capS, x, y, z, mu, n, prover.curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
wBytes := transcript.ExtractBytes([]byte("getw"), 64)
|
||||||
|
w, err := prover.curve.NewScalar().SetBytesWide(wBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
ipp, err := prover.ippProver.rangeToIPP(proofG, hPrime, l, r, tHat, capPhmu, proofGenerators.u.Mul(w), transcript)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
out := &RangeProof{
|
||||||
|
capA: capA,
|
||||||
|
capS: capS,
|
||||||
|
capT1: capT1,
|
||||||
|
capT2: capT2,
|
||||||
|
taux: taux,
|
||||||
|
mu: mu,
|
||||||
|
tHat: tHat,
|
||||||
|
ipp: ipp,
|
||||||
|
curve: &prover.curve,
|
||||||
|
}
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalBinary takes a range proof and marshals into bytes.
|
||||||
|
func (proof *RangeProof) MarshalBinary() []byte {
|
||||||
|
var out []byte
|
||||||
|
out = append(out, proof.capA.ToAffineCompressed()...)
|
||||||
|
out = append(out, proof.capS.ToAffineCompressed()...)
|
||||||
|
out = append(out, proof.capT1.ToAffineCompressed()...)
|
||||||
|
out = append(out, proof.capT2.ToAffineCompressed()...)
|
||||||
|
out = append(out, proof.taux.Bytes()...)
|
||||||
|
out = append(out, proof.mu.Bytes()...)
|
||||||
|
out = append(out, proof.tHat.Bytes()...)
|
||||||
|
out = append(out, proof.ipp.MarshalBinary()...)
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalBinary takes bytes of a marshaled proof and writes them into a range proof
|
||||||
|
// The range proof used should be from the output of NewRangeProof().
|
||||||
|
func (proof *RangeProof) UnmarshalBinary(data []byte) error {
|
||||||
|
scalarLen := len(proof.curve.NewScalar().Bytes())
|
||||||
|
pointLen := len(proof.curve.NewGeneratorPoint().ToAffineCompressed())
|
||||||
|
ptr := 0
|
||||||
|
// Get points
|
||||||
|
capA, err := proof.curve.Point.FromAffineCompressed(data[ptr : ptr+pointLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary FromAffineCompressed")
|
||||||
|
}
|
||||||
|
proof.capA = capA
|
||||||
|
ptr += pointLen
|
||||||
|
capS, err := proof.curve.Point.FromAffineCompressed(data[ptr : ptr+pointLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary FromAffineCompressed")
|
||||||
|
}
|
||||||
|
proof.capS = capS
|
||||||
|
ptr += pointLen
|
||||||
|
capT1, err := proof.curve.Point.FromAffineCompressed(data[ptr : ptr+pointLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary FromAffineCompressed")
|
||||||
|
}
|
||||||
|
proof.capT1 = capT1
|
||||||
|
ptr += pointLen
|
||||||
|
capT2, err := proof.curve.Point.FromAffineCompressed(data[ptr : ptr+pointLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary FromAffineCompressed")
|
||||||
|
}
|
||||||
|
proof.capT2 = capT2
|
||||||
|
ptr += pointLen
|
||||||
|
|
||||||
|
// Get scalars
|
||||||
|
taux, err := proof.curve.NewScalar().SetBytes(data[ptr : ptr+scalarLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary SetBytes")
|
||||||
|
}
|
||||||
|
proof.taux = taux
|
||||||
|
ptr += scalarLen
|
||||||
|
mu, err := proof.curve.NewScalar().SetBytes(data[ptr : ptr+scalarLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary SetBytes")
|
||||||
|
}
|
||||||
|
proof.mu = mu
|
||||||
|
ptr += scalarLen
|
||||||
|
tHat, err := proof.curve.NewScalar().SetBytes(data[ptr : ptr+scalarLen])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary SetBytes")
|
||||||
|
}
|
||||||
|
proof.tHat = tHat
|
||||||
|
ptr += scalarLen
|
||||||
|
|
||||||
|
// Get IPP
|
||||||
|
err = proof.ipp.UnmarshalBinary(data[ptr:])
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("rangeProof UnmarshalBinary")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkRange validates whether some scalar v is within the range [0, 2^n - 1]
|
||||||
|
// It will return an error if v is less than 0 or greater than 2^n - 1
|
||||||
|
// Otherwise it will return nil.
|
||||||
|
func checkRange(v curves.Scalar, n int) error {
|
||||||
|
bigOne := big.NewInt(1)
|
||||||
|
if n < 0 {
|
||||||
|
return errors.New("n cannot be less than 0")
|
||||||
|
}
|
||||||
|
var bigTwoToN big.Int
|
||||||
|
bigTwoToN.Lsh(bigOne, uint(n))
|
||||||
|
if v.BigInt().Cmp(&bigTwoToN) == 1 {
|
||||||
|
return errors.New("v is greater than 2^n")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getBlindingVector returns a vector of scalars used as blinding factors for commitments.
|
||||||
|
func getBlindingVector(length int, curve curves.Curve) []curves.Scalar {
|
||||||
|
vec := make([]curves.Scalar, length)
|
||||||
|
for i := 0; i < length; i++ {
|
||||||
|
vec[i] = curve.Scalar.Random(crand.Reader)
|
||||||
|
}
|
||||||
|
return vec
|
||||||
|
}
|
||||||
|
|
||||||
|
// getcapV returns a commitment to v using blinding factor gamma.
|
||||||
|
func getcapV(v, gamma curves.Scalar, g, h curves.Point) curves.Point {
|
||||||
|
return h.Mul(gamma).Add(g.Mul(v))
|
||||||
|
}
|
||||||
|
|
||||||
|
// getaL obtains the bit vector representation of v
|
||||||
|
// See the a_L definition towards the bottom of pg 17 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func getaL(v curves.Scalar, n int, curve curves.Curve) ([]curves.Scalar, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
vBytes := v.Bytes()
|
||||||
|
zero := curve.Scalar.Zero()
|
||||||
|
one := curve.Scalar.One()
|
||||||
|
aL := make([]curves.Scalar, n)
|
||||||
|
for j := 0; j < len(aL); j++ {
|
||||||
|
aL[j] = zero
|
||||||
|
}
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
ithBit := vBytes[i>>3] >> (i & 0x07) & 0x01
|
||||||
|
aL[i], err = cmoveScalar(zero, one, int(ithBit), curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "getaL")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return aL, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// cmoveScalar provides a constant time operation that returns x if which is 0 and returns y if which is 1.
|
||||||
|
func cmoveScalar(x, y curves.Scalar, which int, curve curves.Curve) (curves.Scalar, error) {
|
||||||
|
if which != 0 && which != 1 {
|
||||||
|
return nil, errors.New("cmoveScalar which must be 0 or 1")
|
||||||
|
}
|
||||||
|
mask := -byte(which)
|
||||||
|
xBytes := x.Bytes()
|
||||||
|
yBytes := y.Bytes()
|
||||||
|
for i, xByte := range xBytes {
|
||||||
|
xBytes[i] ^= (xByte ^ yBytes[i]) & mask
|
||||||
|
}
|
||||||
|
out, err := curve.NewScalar().SetBytes(xBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "cmoveScalar SetBytes")
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// calcyz uses a merlin transcript for Fiat Shamir
|
||||||
|
// It takes the current state of the transcript and appends the newly calculated capA and capS values
|
||||||
|
// Two new scalars are then read from the transcript
|
||||||
|
// See section 4.4 pg22 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func calcyz(capV, capA, capS curves.Point, transcript *merlin.Transcript, curve curves.Curve) (curves.Scalar, curves.Scalar, error) {
|
||||||
|
// Add the A,S values to transcript
|
||||||
|
transcript.AppendMessage([]byte("addV"), capV.ToAffineUncompressed())
|
||||||
|
transcript.AppendMessage([]byte("addcapA"), capA.ToAffineUncompressed())
|
||||||
|
transcript.AppendMessage([]byte("addcapS"), capS.ToAffineUncompressed())
|
||||||
|
// Read 64 bytes twice from, set to scalar for y and z
|
||||||
|
yBytes := transcript.ExtractBytes([]byte("gety"), 64)
|
||||||
|
y, err := curve.NewScalar().SetBytesWide(yBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "calcyz NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
zBytes := transcript.ExtractBytes([]byte("getz"), 64)
|
||||||
|
z, err := curve.NewScalar().SetBytesWide(zBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, errors.Wrap(err, "calcyz NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
|
||||||
|
return y, z, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// calcx uses a merlin transcript for Fiat Shamir
|
||||||
|
// It takes the current state of the transcript and appends the newly calculated capT1 and capT2 values
|
||||||
|
// A new scalar is then read from the transcript
|
||||||
|
// See section 4.4 pg22 of https://eprint.iacr.org/2017/1066.pdf
|
||||||
|
func calcx(capT1, capT2 curves.Point, transcript *merlin.Transcript, curve curves.Curve) (curves.Scalar, error) {
|
||||||
|
// Add the Tau1,2 values to transcript
|
||||||
|
transcript.AppendMessage([]byte("addcapT1"), capT1.ToAffineUncompressed())
|
||||||
|
transcript.AppendMessage([]byte("addcapT2"), capT2.ToAffineUncompressed())
|
||||||
|
// Read 64 bytes from, set to scalar
|
||||||
|
outBytes := transcript.ExtractBytes([]byte("getx"), 64)
|
||||||
|
x, err := curve.NewScalar().SetBytesWide(outBytes)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "calcx NewScalar SetBytesWide")
|
||||||
|
}
|
||||||
|
|
||||||
|
return x, nil
|
||||||
|
}
|
||||||
Executable
+86
@@ -0,0 +1,86 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRangeProverHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 256
|
||||||
|
prover, err := NewRangeProver(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := curve.Scalar.Random(crand.Reader)
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, proof)
|
||||||
|
require.Equal(t, 8, len(proof.ipp.capLs))
|
||||||
|
require.Equal(t, 8, len(proof.ipp.capRs))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetaL(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
v := curve.Scalar.Random(crand.Reader)
|
||||||
|
aL, err := getaL(v, 256, *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
twoN := get2nVector(256, *curve)
|
||||||
|
product, err := innerProduct(aL, twoN)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, product.Cmp(v))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCmove(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
two := curve.Scalar.One().Double()
|
||||||
|
four := two.Double()
|
||||||
|
out, err := cmoveScalar(two, four, 1, *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.Zero(t, out.Cmp(four))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeProverMarshal(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 256
|
||||||
|
prover, err := NewRangeProver(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := curve.Scalar.Random(crand.Reader)
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
proofMarshaled := proof.MarshalBinary()
|
||||||
|
proofPrime := NewRangeProof(curve)
|
||||||
|
err = proofPrime.UnmarshalBinary(proofMarshaled)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, proof.capA.Equal(proofPrime.capA))
|
||||||
|
require.True(t, proof.capS.Equal(proofPrime.capS))
|
||||||
|
require.True(t, proof.capT1.Equal(proofPrime.capT1))
|
||||||
|
require.True(t, proof.capT2.Equal(proofPrime.capT2))
|
||||||
|
require.Zero(t, proof.taux.Cmp(proofPrime.taux))
|
||||||
|
require.Zero(t, proof.mu.Cmp(proofPrime.mu))
|
||||||
|
require.Zero(t, proof.tHat.Cmp(proofPrime.tHat))
|
||||||
|
}
|
||||||
Executable
+187
@@ -0,0 +1,187 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/pkg/errors"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RangeVerifier is the struct used to verify RangeProofs
|
||||||
|
// It specifies which curve to use and holds precomputed generators
|
||||||
|
// See NewRangeVerifier() for verifier initialization.
|
||||||
|
type RangeVerifier struct {
|
||||||
|
curve curves.Curve
|
||||||
|
generators *ippGenerators
|
||||||
|
ippVerifier *InnerProductVerifier
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRangeVerifier initializes a new verifier
|
||||||
|
// It uses the specified domain to generate generators for vectors of at most maxVectorLength
|
||||||
|
// A verifier can be used to verify range proofs for vectors of length less than or equal to maxVectorLength
|
||||||
|
// A verifier is defined by an explicit curve.
|
||||||
|
func NewRangeVerifier(maxVectorLength int, rangeDomain, ippDomain []byte, curve curves.Curve) (*RangeVerifier, error) {
|
||||||
|
generators, err := getGeneratorPoints(maxVectorLength, rangeDomain, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "range NewRangeProver")
|
||||||
|
}
|
||||||
|
ippVerifier, err := NewInnerProductVerifier(maxVectorLength, ippDomain, curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "range NewRangeProver")
|
||||||
|
}
|
||||||
|
return &RangeVerifier{curve: curve, generators: generators, ippVerifier: ippVerifier}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify verifies the given range proof inputs
|
||||||
|
// It implements the checking of L65 on pg 20
|
||||||
|
// It also verifies the dot product of <l,r> using the inner product proof\
|
||||||
|
// capV is a commitment to v using blinding factor gamma
|
||||||
|
// n is the power that specifies the upper bound of the range, ie. 2^n
|
||||||
|
// g, h, u are unique points used as generators for the blinding factor
|
||||||
|
// transcript is a merlin transcript to be used for the fiat shamir heuristic.
|
||||||
|
func (verifier *RangeVerifier) Verify(proof *RangeProof, capV curves.Point, proofGenerators RangeProofGenerators, n int, transcript *merlin.Transcript) (bool, error) {
|
||||||
|
// Length of vectors must be less than the number of generators generated
|
||||||
|
if n > len(verifier.generators.G) {
|
||||||
|
return false, errors.New("ipp vector length must be less than maxVectorLength")
|
||||||
|
}
|
||||||
|
// In case where len(a) is less than number of generators precomputed by prover, trim to length
|
||||||
|
proofG := verifier.generators.G[0:n]
|
||||||
|
proofH := verifier.generators.H[0:n]
|
||||||
|
|
||||||
|
// Calc y,z,x from Fiat Shamir heuristic
|
||||||
|
y, z, err := calcyz(capV, proof.capA, proof.capS, transcript, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
x, err := calcx(proof.capT1, proof.capT2, transcript, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
wBytes := transcript.ExtractBytes([]byte("getw"), 64)
|
||||||
|
w, err := verifier.curve.NewScalar().SetBytesWide(wBytes)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof prove")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calc delta(y,z)
|
||||||
|
deltayz, err := deltayz(y, z, n, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check tHat: L65, pg20
|
||||||
|
tHatIsValid := verifier.checktHat(proof, capV, proofGenerators.g, proofGenerators.h, deltayz, x, z)
|
||||||
|
if !tHatIsValid {
|
||||||
|
return false, errors.New("rangeproof verify tHat is invalid")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verify IPP
|
||||||
|
hPrime, err := gethPrime(proofH, y, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
capPhmu, err := getPhmu(proofG, hPrime, proofGenerators.h, proof.capA, proof.capS, x, y, z, proof.mu, n, verifier.curve)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
ippVerified, err := verifier.ippVerifier.VerifyFromRangeProof(proofG, hPrime, capPhmu, proofGenerators.u.Mul(w), proof.tHat, proof.ipp, transcript)
|
||||||
|
if err != nil {
|
||||||
|
return false, errors.Wrap(err, "rangeproof verify")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ippVerified, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// L65, pg20.
|
||||||
|
func (*RangeVerifier) checktHat(proof *RangeProof, capV, g, h curves.Point, deltayz, x, z curves.Scalar) bool {
|
||||||
|
// g^tHat * h^tau_x
|
||||||
|
gtHat := g.Mul(proof.tHat)
|
||||||
|
htaux := h.Mul(proof.taux)
|
||||||
|
lhs := gtHat.Add(htaux)
|
||||||
|
|
||||||
|
// V^z^2 * g^delta(y,z) * Tau_1^x * Tau_2^x^2
|
||||||
|
capVzsquare := capV.Mul(z.Square())
|
||||||
|
gdeltayz := g.Mul(deltayz)
|
||||||
|
capTau1x := proof.capT1.Mul(x)
|
||||||
|
capTau2xsquare := proof.capT2.Mul(x.Square())
|
||||||
|
rhs := capVzsquare.Add(gdeltayz).Add(capTau1x).Add(capTau2xsquare)
|
||||||
|
|
||||||
|
// Compare lhs =? rhs
|
||||||
|
return lhs.Equal(rhs)
|
||||||
|
}
|
||||||
|
|
||||||
|
// gethPrime calculates new h prime generators as defined in L64 on pg20.
|
||||||
|
func gethPrime(h []curves.Point, y curves.Scalar, curve curves.Curve) ([]curves.Point, error) {
|
||||||
|
hPrime := make([]curves.Point, len(h))
|
||||||
|
yInv, err := y.Invert()
|
||||||
|
yInvn := getknVector(yInv, len(h), curve)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "gethPrime")
|
||||||
|
}
|
||||||
|
for i, hElem := range h {
|
||||||
|
hPrime[i] = hElem.Mul(yInvn[i])
|
||||||
|
}
|
||||||
|
return hPrime, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain P used for IPP verification
|
||||||
|
// See L67 on pg20
|
||||||
|
// Note P on L66 includes blinding factor hmu, this method removes that factor.
|
||||||
|
func getPhmu(proofG, proofHPrime []curves.Point, h, capA, capS curves.Point, x, y, z, mu curves.Scalar, n int, curve curves.Curve) (curves.Point, error) {
|
||||||
|
// h'^(z*y^n + z^2*2^n)
|
||||||
|
zyn := multiplyScalarToScalarVector(z, getknVector(y, n, curve))
|
||||||
|
zsquaretwon := multiplyScalarToScalarVector(z.Square(), get2nVector(n, curve))
|
||||||
|
elemLastExponent, err := addPairwiseScalarVectors(zyn, zsquaretwon)
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "getPhmu")
|
||||||
|
}
|
||||||
|
lastElem := curve.Point.SumOfProducts(proofHPrime, elemLastExponent)
|
||||||
|
|
||||||
|
// S^x
|
||||||
|
capSx := capS.Mul(x)
|
||||||
|
|
||||||
|
// g^-z --> -z*<1,g>
|
||||||
|
onen := get1nVector(n, curve)
|
||||||
|
zNeg := z.Neg()
|
||||||
|
zinvonen := multiplyScalarToScalarVector(zNeg, onen)
|
||||||
|
zgdotonen := curve.Point.SumOfProducts(proofG, zinvonen)
|
||||||
|
|
||||||
|
// L66 on pg20
|
||||||
|
P := capA.Add(capSx).Add(zgdotonen).Add(lastElem)
|
||||||
|
hmu := h.Mul(mu)
|
||||||
|
Phmu := P.Sub(hmu)
|
||||||
|
|
||||||
|
return Phmu, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delta function for delta(y,z), See (39) on pg18.
|
||||||
|
func deltayz(y, z curves.Scalar, n int, curve curves.Curve) (curves.Scalar, error) {
|
||||||
|
// z - z^2
|
||||||
|
zMinuszsquare := z.Sub(z.Square())
|
||||||
|
// 1^n
|
||||||
|
onen := get1nVector(n, curve)
|
||||||
|
// <1^n, y^n>
|
||||||
|
onendotyn, err := innerProduct(onen, getknVector(y, n, curve))
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "deltayz")
|
||||||
|
}
|
||||||
|
// (z - z^2)*<1^n, y^n>
|
||||||
|
termFirst := zMinuszsquare.Mul(onendotyn)
|
||||||
|
|
||||||
|
// <1^n, 2^n>
|
||||||
|
onendottwon, err := innerProduct(onen, get2nVector(n, curve))
|
||||||
|
if err != nil {
|
||||||
|
return nil, errors.Wrap(err, "deltayz")
|
||||||
|
}
|
||||||
|
// z^3*<1^n, 2^n>
|
||||||
|
termSecond := z.Cube().Mul(onendottwon)
|
||||||
|
|
||||||
|
// (z - z^2)*<1^n, y^n> - z^3*<1^n, 2^n>
|
||||||
|
out := termFirst.Sub(termSecond)
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
Executable
+87
@@ -0,0 +1,87 @@
|
|||||||
|
package bulletproof
|
||||||
|
|
||||||
|
import (
|
||||||
|
crand "crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gtank/merlin"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
|
"github.com/onsonr/sonr/crypto/core/curves"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestRangeVerifyHappyPath(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 256
|
||||||
|
prover, err := NewRangeProver(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := curve.Scalar.Random(crand.Reader)
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewRangeVerifier(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
capV := getcapV(v, gamma, g, h)
|
||||||
|
verified, err := verifier.Verify(proof, capV, proofGenerators, n, transcriptVerifier)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, verified)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeVerifyNotInRange(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 2
|
||||||
|
prover, err := NewRangeProver(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v := curve.Scalar.Random(crand.Reader)
|
||||||
|
gamma := curve.Scalar.Random(crand.Reader)
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
_, err = prover.Prove(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.Error(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRangeVerifyNonRandom(t *testing.T) {
|
||||||
|
curve := curves.ED25519()
|
||||||
|
n := 2
|
||||||
|
prover, err := NewRangeProver(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
v := curve.Scalar.One()
|
||||||
|
gamma := curve.Scalar.Random(crand.Reader)
|
||||||
|
g := curve.Point.Random(crand.Reader)
|
||||||
|
h := curve.Point.Random(crand.Reader)
|
||||||
|
u := curve.Point.Random(crand.Reader)
|
||||||
|
proofGenerators := RangeProofGenerators{
|
||||||
|
g: g,
|
||||||
|
h: h,
|
||||||
|
u: u,
|
||||||
|
}
|
||||||
|
transcript := merlin.NewTranscript("test")
|
||||||
|
proof, err := prover.Prove(v, gamma, n, proofGenerators, transcript)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
verifier, err := NewRangeVerifier(n, []byte("rangeDomain"), []byte("ippDomain"), *curve)
|
||||||
|
require.NoError(t, err)
|
||||||
|
transcriptVerifier := merlin.NewTranscript("test")
|
||||||
|
capV := getcapV(v, gamma, g, h)
|
||||||
|
verified, err := verifier.Verify(proof, capV, proofGenerators, n, transcriptVerifier)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.True(t, verified)
|
||||||
|
}
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
aliases: [README]
|
||||||
|
tags: []
|
||||||
|
title: README
|
||||||
|
linter-yaml-title-alias: README
|
||||||
|
date created: Wednesday, April 17th 2024, 4:11:40 pm
|
||||||
|
date modified: Thursday, April 18th 2024, 8:19:25 am
|
||||||
|
---
|
||||||
|
|
||||||
|
## Core Package
|
||||||
|
|
||||||
|
The core package contains a set of primitives, including but not limited to various
|
||||||
|
elliptic curves, hashes, and commitment schemes. These primitives are used internally
|
||||||
|
and can also be used independently on their own externally.
|
||||||
Executable
+115
@@ -0,0 +1,115 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/hmac"
|
||||||
|
crand "crypto/rand"
|
||||||
|
"crypto/sha256"
|
||||||
|
"crypto/subtle"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"hash"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Size of random values and hash outputs are determined by our hash function
|
||||||
|
const Size = sha256.Size
|
||||||
|
|
||||||
|
type (
|
||||||
|
// Commitment to a given message which can be later revealed.
|
||||||
|
// This is sent to and held by a verifier until the corresponding
|
||||||
|
// witness is provided.
|
||||||
|
Commitment []byte
|
||||||
|
|
||||||
|
// Witness is sent to and opened by the verifier. This proves that
|
||||||
|
// committed message hasn't been altered by later information.
|
||||||
|
Witness struct {
|
||||||
|
Msg []byte
|
||||||
|
r [Size]byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// witnessJSON is used for un/marshaling.
|
||||||
|
witnessJSON struct {
|
||||||
|
Msg []byte
|
||||||
|
R [Size]byte
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// MarshalJSON encodes Witness in JSON
|
||||||
|
func (w Witness) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(witnessJSON{w.Msg, w.r})
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON decodes JSON into a Witness struct
|
||||||
|
func (w *Witness) UnmarshalJSON(data []byte) error {
|
||||||
|
witness := &witnessJSON{}
|
||||||
|
err := json.Unmarshal(data, witness)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
w.Msg = witness.Msg
|
||||||
|
w.r = witness.R
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commit to a given message. Uses SHA256 as the hash function.
|
||||||
|
func Commit(msg []byte) (Commitment, *Witness, error) {
|
||||||
|
// Initialize our decommitment
|
||||||
|
d := Witness{msg, [Size]byte{}}
|
||||||
|
|
||||||
|
// Generate a random nonce of the required length
|
||||||
|
n, err := crand.Read(d.r[:])
|
||||||
|
// Ensure no errors retrieving nonce
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure we read all the bytes expected
|
||||||
|
if n != Size {
|
||||||
|
return nil, nil, fmt.Errorf("failed to read %v bytes from crypto/rand: received %v bytes", Size, n)
|
||||||
|
}
|
||||||
|
// Compute the commitment: HMAC(Sha2, msg, key)
|
||||||
|
c, err := ComputeHMAC(sha256.New, msg, d.r[:])
|
||||||
|
if err != nil {
|
||||||
|
return nil, nil, err
|
||||||
|
}
|
||||||
|
return c, &d, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open a commitment and return true if the commitment/decommitment pair are valid.
|
||||||
|
// reference: spec.§2.4: Commitment Scheme
|
||||||
|
func Open(c Commitment, d Witness) (bool, error) {
|
||||||
|
// Ensure commitment is well-formed.
|
||||||
|
if len(c) != Size {
|
||||||
|
return false, fmt.Errorf("invalid commitment, wrong length. %v != %v", len(c), Size)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Re-compute the commitment: HMAC(Sha2, msg, key)
|
||||||
|
cʹ, err := ComputeHMAC(sha256.New, d.Msg, d.r[:])
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return subtle.ConstantTimeCompare(cʹ, c) == 1, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComputeHMAC computes HMAC(hash_fn, msg, key)
|
||||||
|
// Takes in a hash function to use for HMAC
|
||||||
|
func ComputeHMAC(f func() hash.Hash, msg []byte, k []byte) ([]byte, error) {
|
||||||
|
if f == nil {
|
||||||
|
return nil, fmt.Errorf("hash function cannot be nil")
|
||||||
|
}
|
||||||
|
|
||||||
|
mac := hmac.New(f, k)
|
||||||
|
w, err := mac.Write(msg)
|
||||||
|
|
||||||
|
if w != len(msg) {
|
||||||
|
return nil, fmt.Errorf("bytes written to hash doesn't match expected: %v != %v", w, len(msg))
|
||||||
|
} else if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return mac.Sum(nil), nil
|
||||||
|
}
|
||||||
Executable
+374
@@ -0,0 +1,374 @@
|
|||||||
|
//
|
||||||
|
// Copyright Coinbase, Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
//
|
||||||
|
|
||||||
|
package core
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
// An entry into our test table
|
||||||
|
type entry struct {
|
||||||
|
// Input
|
||||||
|
msg []byte
|
||||||
|
|
||||||
|
// Result (actual, not expected)
|
||||||
|
commit Commitment
|
||||||
|
decommit *Witness
|
||||||
|
err error
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test inputs and placeholders for results that will be filled in
|
||||||
|
// during init()
|
||||||
|
var testResults = []entry{
|
||||||
|
{[]byte("This is a test message"), nil, nil, nil},
|
||||||
|
{[]byte("short msg"), nil, nil, nil},
|
||||||
|
{[]byte("This input field is intentionally longer than the SHA256 block size to ensure that the entire message is processed"),
|
||||||
|
nil, nil, nil},
|
||||||
|
{[]byte{0xFB, 0x1A, 0x18, 0x47, 0x39, 0x3C, 0x9F, 0x45, 0x5F, 0x29, 0x4C, 0x51, 0x42, 0x30, 0xA6, 0xB9},
|
||||||
|
nil, nil, nil},
|
||||||
|
// msg = \epsilon (empty string)
|
||||||
|
{[]byte{}, nil, nil, nil},
|
||||||
|
// msg == nil
|
||||||
|
{nil, nil, nil, nil},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run our inputs through commit and record the outputs
|
||||||
|
func init() {
|
||||||
|
for i := range testResults {
|
||||||
|
entry := &testResults[i]
|
||||||
|
entry.commit, entry.decommit, entry.err = Commit(entry.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Computing commitments should never produce errors
|
||||||
|
func TestCommitWithoutErrors(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
if entry.err != nil {
|
||||||
|
t.Errorf("received Commit(%v): %v", entry.msg, entry.err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commitments should be 256b == 64B in length
|
||||||
|
func TestCommitmentsAreExpectedLength(t *testing.T) {
|
||||||
|
const expLen = 256 / 8
|
||||||
|
for _, entry := range testResults {
|
||||||
|
if len(entry.commit) != expLen {
|
||||||
|
t.Errorf("commitment is not expected length: %v != %v", len(entry.commit), expLen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decommit cannot be nil
|
||||||
|
func TestCommmitProducesDecommit(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
if entry.decommit == nil {
|
||||||
|
t.Errorf("decommit cannot be nil: Commit(%v)", entry.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Decommit value should contain the same message
|
||||||
|
func TestCommmitProducesDecommitWithSameMessage(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
if !bytes.Equal(entry.msg, entry.decommit.Msg) {
|
||||||
|
t.Errorf("decommit.msg != msg: %v != %v", entry.msg, entry.decommit.Msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commitments should be unique
|
||||||
|
func TestCommmitProducesDistinctCommitments(t *testing.T) {
|
||||||
|
seen := make(map[[Size]byte]bool)
|
||||||
|
|
||||||
|
// Check the pre-computed commitments for uniquness
|
||||||
|
for _, entry := range testResults {
|
||||||
|
|
||||||
|
// Slices cannot be used as hash keys, so we need to copy into
|
||||||
|
// an array. Oh, go-lang.
|
||||||
|
var cee [Size]byte
|
||||||
|
copy(cee[:], entry.commit)
|
||||||
|
|
||||||
|
// Ensure each commit is unique
|
||||||
|
if seen[cee] {
|
||||||
|
t.Errorf("duplicate commit found: %v", cee)
|
||||||
|
}
|
||||||
|
seen[cee] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Commitments should be unique even for the same message since the nonce is
|
||||||
|
// randomly selected
|
||||||
|
func TestCommmitDistinctCommitments(t *testing.T) {
|
||||||
|
seen := make(map[[Size]byte]bool)
|
||||||
|
msg := []byte("black lives matter")
|
||||||
|
const iterations = 1000
|
||||||
|
|
||||||
|
// Check the pre-computed commitments for uniquness
|
||||||
|
for i := 0; i < iterations; i++ {
|
||||||
|
// Compute a commitment
|
||||||
|
c, _, err := Commit(msg)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slices cannot be used as hash keys, so copy into an array
|
||||||
|
var cee [Size]byte
|
||||||
|
copy(cee[:], []byte(c))
|
||||||
|
|
||||||
|
// Ensure each commit is unique
|
||||||
|
if seen[cee] {
|
||||||
|
t.Errorf("duplicate commit found: %v", cee)
|
||||||
|
}
|
||||||
|
seen[cee] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nonces must be 256b = 64B
|
||||||
|
func TestCommmitNonceIsExpectedLength(t *testing.T) {
|
||||||
|
const expLen = 256 / 8
|
||||||
|
|
||||||
|
// Check the pre-computed nonces
|
||||||
|
for _, entry := range testResults {
|
||||||
|
if len(entry.decommit.r) != expLen {
|
||||||
|
t.Errorf("nonce is not expected length: %v != %v", len(entry.decommit.r), expLen)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Randomly selected nonces will be unique with overwhelming probability
|
||||||
|
func TestCommmitProducesDistinctNonces(t *testing.T) {
|
||||||
|
seen := make(map[[Size]byte]bool)
|
||||||
|
msg := []byte("black lives matter")
|
||||||
|
const iterations = 1000
|
||||||
|
|
||||||
|
// Check the pre-computed commitments for uniquness
|
||||||
|
for i := 0; i < iterations; i++ {
|
||||||
|
// Compute a commitment
|
||||||
|
_, dee, err := Commit(msg)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure each nonce is unique
|
||||||
|
if seen[dee.r] {
|
||||||
|
t.Errorf("duplicate nonce found: %v", dee.r)
|
||||||
|
}
|
||||||
|
seen[dee.r] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenOnValidCommitments(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
|
||||||
|
// Open each commitment
|
||||||
|
ok, err := Open(entry.commit, *entry.decommit)
|
||||||
|
|
||||||
|
// There should be no error
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// The commitments should verify
|
||||||
|
if !ok {
|
||||||
|
t.Errorf("commitment failed to open: %v", entry.msg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenOnModifiedNonce(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
dʹ := copyWitness(entry.decommit)
|
||||||
|
|
||||||
|
// Modify the nonce
|
||||||
|
dʹ.r[0] ^= 0x40
|
||||||
|
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(entry.commit, *dʹ)
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOpenOnZeroPrefixNonce(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
dʹ := copyWitness(entry.decommit)
|
||||||
|
|
||||||
|
// Modify the nonce
|
||||||
|
dʹ.r[0] = 0x00
|
||||||
|
dʹ.r[1] = 0x00
|
||||||
|
dʹ.r[2] = 0x00
|
||||||
|
dʹ.r[3] = 0x00
|
||||||
|
dʹ.r[4] = 0x00
|
||||||
|
dʹ.r[5] = 0x00
|
||||||
|
dʹ.r[6] = 0x00
|
||||||
|
dʹ.r[7] = 0x00
|
||||||
|
dʹ.r[8] = 0x00
|
||||||
|
dʹ.r[9] = 0x00
|
||||||
|
dʹ.r[10] = 0x00
|
||||||
|
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(entry.commit, *dʹ)
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Makes a deep copy of a Witness
|
||||||
|
func copyWitness(d *Witness) *Witness {
|
||||||
|
msg := make([]byte, len(d.Msg))
|
||||||
|
var r [Size]byte
|
||||||
|
|
||||||
|
copy(msg, d.Msg)
|
||||||
|
copy(r[:], d.r[:])
|
||||||
|
return &Witness{msg, r}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Asserts that err != nil, and ok == false.
|
||||||
|
func assertFailedOpen(t *testing.T, ok bool, err error) {
|
||||||
|
// There should be no error
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// But the commitments should fail
|
||||||
|
if ok {
|
||||||
|
t.Error("commitment was verified but was expected to fail")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// An unrelated message should fail on open
|
||||||
|
func TestOpenOnNewMessage(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
dʹ := copyWitness(entry.decommit)
|
||||||
|
|
||||||
|
// Use a distinct message
|
||||||
|
dʹ.Msg = []byte("no one expects the spanish inquisition")
|
||||||
|
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(entry.commit, *dʹ)
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// An appended message should fail on open
|
||||||
|
func TestOpenOnAppendedMessage(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
dʹ := copyWitness(entry.decommit)
|
||||||
|
|
||||||
|
// Modify the message
|
||||||
|
dʹ.Msg = []byte("no one expects the spanish inquisition")
|
||||||
|
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(entry.commit, *dʹ)
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A modified message should fail on open
|
||||||
|
func TestOpenOnModifiedMessage(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
// Skip the empty string message for this test case
|
||||||
|
if len(entry.msg) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify the message _in situ_
|
||||||
|
dʹ := copyWitness(entry.decommit)
|
||||||
|
dʹ.Msg[1] ^= 0x99
|
||||||
|
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(entry.commit, *dʹ)
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A modified commitment should fail on open
|
||||||
|
func TestOpenOnModifiedCommitment(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
// Copy and then modify the commitment
|
||||||
|
cʹ := make([]byte, Size)
|
||||||
|
copy(cʹ[:], entry.commit)
|
||||||
|
cʹ[6] ^= 0x33
|
||||||
|
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(cʹ, *entry.decommit)
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// An empty decommit should fail to open
|
||||||
|
func TestOpenOnDefaultDecommitObject(t *testing.T) {
|
||||||
|
for _, entry := range testResults {
|
||||||
|
// Open and check for failure
|
||||||
|
ok, err := Open(entry.commit, Witness{})
|
||||||
|
assertFailedOpen(t, ok, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A nil commit should return an error
|
||||||
|
func TestOpenOnNilCommitment(t *testing.T) {
|
||||||
|
_, err := Open(nil, Witness{})
|
||||||
|
assertError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifies that err != nil
|
||||||
|
func assertError(t *testing.T, err error) {
|
||||||
|
if err == nil {
|
||||||
|
t.Error("expected an error but received nil")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ill-formed commitment should produce an error
|
||||||
|
func TestOpenOnLongCommitment(t *testing.T) {
|
||||||
|
tooLong := make([]byte, Size+1)
|
||||||
|
_, err := Open(tooLong, Witness{})
|
||||||
|
assertError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ill-formed commitment should produce an error
|
||||||
|
func TestOpenOnShortCommitment(t *testing.T) {
|
||||||
|
tooShort := make([]byte, Size-1)
|
||||||
|
_, err := Open(tooShort, Witness{})
|
||||||
|
assertError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests that marshal-unmarshal is the identity function
|
||||||
|
func TestWitnessMarshalRoundTrip(t *testing.T) {
|
||||||
|
expected := &Witness{
|
||||||
|
[]byte("I'm the dude. So that's what you call me"),
|
||||||
|
[Size]byte{0xAC},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Marhal and test
|
||||||
|
jsonBytes, err := json.Marshal(expected)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, jsonBytes)
|
||||||
|
|
||||||
|
// Unmarshal and test
|
||||||
|
actual := &Witness{}
|
||||||
|
require.NoError(t, json.Unmarshal(jsonBytes, actual))
|
||||||
|
require.Equal(t, expected.Msg, actual.Msg)
|
||||||
|
require.Equal(t, expected.r, actual.r)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests that marshal-unmarshal is the identity function
|
||||||
|
func TestCommitmentMarshalRoundTrip(t *testing.T) {
|
||||||
|
expected := Commitment([]byte("That or uh his-dudeness or duder or el duderino."))
|
||||||
|
|
||||||
|
// Marhal and test
|
||||||
|
jsonBytes, err := json.Marshal(expected)
|
||||||
|
require.NoError(t, err)
|
||||||
|
require.NotNil(t, jsonBytes)
|
||||||
|
|
||||||
|
// Unmarshal and test
|
||||||
|
actual := Commitment{}
|
||||||
|
require.NoError(t, json.Unmarshal(jsonBytes, &actual))
|
||||||
|
require.Equal(t, []byte(expected), []byte(actual))
|
||||||
|
}
|
||||||
Executable
+1226
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user