Skip to content

Commit

Permalink
KeyGen in die GUI eingebaut
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-H11 committed Apr 7, 2024
1 parent b272678 commit 5735c23
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions GUI/src/app/menezes-vanstone/menezes-vanstone.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
<mat-label>Modulbreite</mat-label>
<input class="text-align-right" matInput type="number" [(ngModel)]="modulusWidth">
<span matTextSuffix>-Bit</span>
<mat-hint>Bei {{numberSystem}} mindestens {{calcMinimumBitsize()}} Bit</mat-hint>
</mat-form-field>

<mat-form-field appearance="outline" class="config-form-field">
<mat-label>Zahlensystem</mat-label>
<input class="text-align-right" matInput type="number" [(ngModel)]="numberSystem">
<mat-hint>Bei {{modulusWidth}}-Bit maximal {{calcMaxNumbersystem()}}</mat-hint>
</mat-form-field>

<mat-form-field appearance="outline" class="config-form-field">
Expand All @@ -32,6 +34,11 @@
<mat-hint>wird '-a^2'</mat-hint>
</mat-form-field>

<mat-form-field appearance="outline" class="config-form-field">
<mat-label>Seed</mat-label>
<input class="text-align-right" matInput type="number" [(ngModel)]="random_seed">
</mat-form-field>

<mat-action-row class="action-row-content-left">
<button mat-flat-button *ngFor="let client of clients" color="primary" (click)="generateKeys(client.name)">
Schlüsselpaar für {{client.name}} erzeugen
Expand Down Expand Up @@ -63,6 +70,7 @@
Punkte: {{JSON.stringify(client.ciphertext.points)}}

<mat-action-row>
<button mat-flat-button color="primary" (click)="clearFields(client.name)">Löschen</button>
<button mat-flat-button color="primary" [disabled]="client.plaintext.length<1" (click)="encrypt(client.name)">Verschlüsseln</button>
<button mat-flat-button color="primary" [disabled]="client.ciphertext.encrypted_message.length<1" (click)="decrypt(client.name)">Entschlüsseln</button>
<button mat-flat-button color="primary" (click)="send(client.name)">Senden</button>
Expand Down
18 changes: 17 additions & 1 deletion GUI/src/app/menezes-vanstone/menezes-vanstone.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class MenezesVanstoneComponent {
public numberSystem: number = 55296;
public millerRabinIterations: number = 100;
public coefficientA: number = 5;
public random_seed: number= 3;

public clients: ClientData[] =
[
Expand Down Expand Up @@ -141,7 +142,8 @@ export class MenezesVanstoneComponent {
let config: MvKeygenConfig = {
modulus_width: this.modulusWidth,
miller_rabin_rounds: this.millerRabinIterations,
coef_a: this.coefficientA
coef_a: this.coefficientA,
random_seed: this.random_seed
};
this.backendRequestService.createKeyPair(config).then(key => {
if (client === "Alice") {
Expand Down Expand Up @@ -191,5 +193,19 @@ export class MenezesVanstoneComponent {
client.ciphertext = {encrypted_message: "", points: []};
}

public clearFields(name: string) {
let client = (name === "Alice") ? this.clients[0] : this.clients[1];
client.plaintext = "";
client.ciphertext = {encrypted_message: "", points: []};
}

protected readonly JSON = JSON;

public calcMinimumBitsize(): number {
return Math.ceil(Math.log2(this.numberSystem));
}

public calcMaxNumbersystem(): number {
return 2 ** this.modulusWidth;
}
}
5 changes: 4 additions & 1 deletion GUI/src/app/models/mv-keygen-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ export class MvKeygenConfig {
modulus_width: number;
miller_rabin_rounds: number;
coef_a: number;
random_seed: number;

constructor(modulus_width: number,
miller_rabin_rounds: number,
coef_a: number) {
coef_a: number,
random_seed: number) {
this.modulus_width = modulus_width;
this.miller_rabin_rounds = miller_rabin_rounds;
this.coef_a = coef_a;
this.random_seed = random_seed;
}
}

0 comments on commit 5735c23

Please sign in to comment.