Skip to content

Commit

Permalink
Added basic description
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSchmidt committed Apr 18, 2024
1 parent e33abfc commit 4d059ae
Show file tree
Hide file tree
Showing 4 changed files with 607 additions and 1 deletion.
159 changes: 159 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
root = true


[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space

[*.yaml]
indent_size = 2

[*.json]
indent_size = 4

[*.sh]
indent_size = 4

[Makefile]
indent_style = tab

[*.cs]
indent_size = 4

[*.{csproj,Build.props,Build.targets}]
indent_size = 2

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = false
csharp_new_line_before_members_in_anonymous_types = false
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents = true
csharp_indent_case_contents_when_block = false
csharp_indent_switch_labels = true
csharp_indent_labels = no_change

# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning

# avoid this. unless absolutely necessary
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Types: use keywords instead of BCL types
csharp_style_var_for_built_in_types = true:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:error
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:error

# Name all private, internal and private protected fields using prefix_
dotnet_naming_rule.private_members_with_underscore.severity = error
dotnet_naming_rule.private_members_with_underscore.style = prefix_underscore
dotnet_naming_rule.private_members_with_underscore.symbols = private_fields
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_style.prefix_underscore.capitalization = camel_case
dotnet_naming_style.prefix_underscore.required_prefix = _

## constant fields should be PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = error
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Name all public and protected fields using PascalCase
dotnet_naming_rule.public_fields_should_be_pascal_case.severity = error
dotnet_naming_rule.public_fields_should_be_pascal_case.symbols = public_fields
dotnet_naming_rule.public_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.public_fields.applicable_kinds = field
dotnet_naming_symbols.public_fields.applicable_accessibilities = public, protected
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# Code style defaults
csharp_using_directive_placement = outside_namespace:error
dotnet_sort_system_directives_first = true
csharp_prefer_braces = when_multiline:suggestion
csharp_preserve_single_line_blocks = true:none
csharp_preserve_single_line_statements = false:none
csharp_prefer_static_local_function = true:suggestion
csharp_prefer_simple_using_statement = true:warning
csharp_style_prefer_switch_expression = true:suggestion
dotnet_style_readonly_field = true:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:error
dotnet_style_prefer_conditional_expression_over_assignment = true:warning
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
csharp_prefer_simple_default_expression = true:warning

# Expression-bodied members
csharp_style_expression_bodied_methods = true:suggestion
csharp_style_expression_bodied_constructors = true:suggestion
csharp_style_expression_bodied_operators = true:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion
csharp_style_expression_bodied_lambdas = true:suggestion
csharp_style_expression_bodied_local_functions = true:suggestion

# Pattern matching
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# Null checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Other features
csharp_style_prefer_index_operator = false:none
csharp_style_prefer_range_operator = false:none
csharp_style_pattern_local_over_anonymous_function = false:none

# Space preferences
csharp_space_after_cast = false
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_after_comma = true
csharp_space_after_dot = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_after_semicolon_in_for_statement = true
csharp_space_around_binary_operators = before_and_after
csharp_space_around_declaration_statements = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_before_comma = false
csharp_space_before_dot = false
csharp_space_before_open_square_brackets = false
csharp_space_before_semicolon_in_for_statement = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_between_square_brackets = false
76 changes: 76 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# ignore dotnet code coverage files
**/coverage.cobertura.xml

# Created by https://www.toptal.com/developers/gitignore/api/dotnetcore,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=dotnetcore,macos

### DotnetCore ###
# .NET Core build folders
bin/
obj/

# Common node modules locations
/node_modules
/wwwroot/node_modules

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# IDEA (Rider)
**/.idea


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

# TestResults (dotnet)
**/TestResults/

### VisualStudioCode ###
.vscode/* # Maybe .vscode/**/* instead - see comments
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

### VisualStudioCode Patch ###
# Ignore all local history of files
**/.history

# End of https://www.gitignore.io/api/visualstudiocode

# End of https://www.toptal.com/developers/gitignore/api/dotnetcore,macos
/src/.vs
.vs/

# Ignore Visual Studio user-specific files
*.user

# Ignore Verify.xUnit received files
*.received.txt
91 changes: 90 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,90 @@
# chronicler
# Project Origin - OriginChronicler

OpenSource project to create a service which can record claims for a area based on the rules of the Project Origin.

The name `OriginChronicler` is a play on words,
where `Origin` links to the project's name, while `Chronicler` refers to the service' purpose of recording claims
to enable statistics.

## tl:dr

The OriginChronicler project aims to provide a service where all claims data for a issuers area can be recorded for statistic purposes.

The service will be able to sign claims, and the registry can verify the signature of the claim to ensure that the claim has been registered.

The service will not know the owner of the claim, only the size of the claim. This ensures that the privacy of the owner is kept.

The service will be able to provide statistics on how much has been claimed within an area.

## Problem Statement

In the Project-Origin all Granular Certificate data is "hidden" on the registries using homomorphic encryption (Pedersen commitments).

This ensures that all the data is kept private, and only the owner of a slice can prove the size of their slices and data to others.
This data is stored within the owners wallet.

The issuers would know how much has been issued and to whom.

But there is no way to know how much of the energy is claimed or not, and for statistics purposes this is needed.

## Context

Users might hold their assets in any wallet, and energy produced might be claimed against any consumption also in other areas.

The data is stored in the users wallet, but the data is not shared with the issuer or any other party.

## Forces

It is a requirement for a country to be able to know how much of the energy produced is claimed or not.

The data is stored in the users wallet, but the data is not shared with the issuer or any other party.

## Solution

The solution is to create a requirement for a claim to be co-signed by the chronicle service and the owner.
Basically the owner registers the claim with the chronicle service, and the chronicle service signs the claim before it is sent to registry.

The registry can then check the signature of the chronicle service to ensure that the claim has been registered.

The chronicle service will then be able to provide statistics on how much of the energy produced is claimed or not.

This requires an additional rule to be added to the Energy Tack & Trace rules.

## Sketch

Below is a C4 system diagram of an overview of the system landscape OriginChronicler is a part of.

![C4 System Diagram](./doc/diagrams/system-c4.drawio.svg)

## Suggested call flow

Below is a sequence diagram of the call flow between the wallet, chronicler and registry.

```mermaid
sequenceDiagram
actor owner
participant wallet
participant chronicler
participant registry
owner->>+wallet: Create claim
wallet->>wallet: create commitment
wallet->>+chronicler: send commitment info and FID
chronicler->>chronicler: store commitment info and FID
chronicler->>-wallet: return signature
wallet->>+registry: send claim with signature
deactivate wallet
registry->>registry: verify transaction and signature
deactivate registry
```

## Resulting Context

The statistical entity running the OriginChronicler is now able to provide statistics
on how much has been claimed within an area in a verifiable and trustable way without compromising the privacy of the users.

The registry never needs to know the data or call the chronicle service,
it only needs to verify the transactions as always, and verify the signature of the chronicle service that the claim has been registered.

The chronicle service now knows the size of each claim for the given area, but importantly it does not know the owner of the claim.
Loading

0 comments on commit 4d059ae

Please sign in to comment.