web.signature #
fn debug #
fn debug(mut ctx Context) bool
fn new #
fn new(config SignerConfig) &Signer
fn run #
fn run()
struct App #
struct App {
veb.StaticHandler
veb.Middleware[Context]
pub mut:
signer &Signer
}
fn (App) generate_root_key #
fn (app &App) generate_root_key(mut ctx Context) veb.Result
Endpoint to generate a root key for the user
fn (App) derive_key #
fn (app &App) derive_key(mut ctx Context) veb.Result
Endpoint to derive a key from the root key
fn (App) sign_document #
fn (app &App) sign_document(mut ctx Context) veb.Result
Endpoint to sign a document hash and timestamp
fn (App) verify_signature #
fn (app &App) verify_signature(mut ctx Context) veb.Result
Endpoint to verify a signature
fn (App) index #
fn (app &App) index(mut ctx Context) veb.Result
struct Context #
struct Context {
veb.Context
}
Struct to represent the user root keys and signatures
struct Signer #
struct Signer {
secret string
pub mut:
db sqlite.DB
}
fn (Signer) generate_root_key #
fn (s Signer) generate_root_key(user string) string
generate a root key for the user
fn (Signer) derive_key #
fn (s Signer) derive_key(root_key string, index string) string
derive a key from the root key
fn (Signer) sign_document #
fn (s Signer) sign_document(derived_key string, filename string, file_hash string) !
sign a document hash and timestamp
fn (Signer) verify_signature #
fn (s Signer) verify_signature(filename string, user_signature string) !
Endpoint to verify a signature
struct SignerConfig #
@[params]
struct SignerConfig {
db_path string = 'signatures.sqlite'
}